This is driving me batty. I.m setting up a spreadsheet that is taking data from Access. Once the data is placed in Excel I need to massage it a bit. part of that massaging is to insert some columns. So I carefully recorded a macro to go through the steps
of selecting the columns, then entering the column headers. and saving the macro. I then deleted the inserted columns and ran the macro. Worked perfectly.
So next, I tried to tweak the macro a bit to make it more dynamic and it stopped working at selecting the right range of columns.
The original recorded code was:
Columns("X:AI").Select
Selection.Insert Shift:=xlToRight
I added these two lines:
Dim intStartYr As Integer
intStartYr = Year(Date) - 6
Now, when I run the macro it select X:CO and I have no clue why. I even tried recording the macro and it still does the same.
I'm about to give up and just have the user do it manually. But I figured I'd ask here to see if anyone can shed some light on this.