Hi all,
I currently use the below code to select the first empty cell on row 2 and then do a vlookup formula and finally auto fill that formula to the bottom of the data (I have not pasted the vlookup line as it is irrelevant).
Cells(2, Range("A2").End(xlToRight).Column + 1).Select - This selects the first empty cell on row 2
*VLOOKUP FORMULA*
Selection.AutoFill Destination:=Range("B2:B" & Range("A" & Rows.Count).End(xlUp).Row)
Range(Selection, Selection.End(xlDown)).Select - This auto fills to the bottom of the data for the cell selected in step 1. However I can no longer use this as I need the range to be dynamic.
My problem is that the second line of code states cells "B2:B" but this won't always be the same range. I need this range to be the same as the one selected during the first line of code.
Is there anything I can add to the auto fill code, to always select the same range as the one selected in step 1, rather than always selecting column B (which was the first set of data ran)?
Thanks in advance.
I currently use the below code to select the first empty cell on row 2 and then do a vlookup formula and finally auto fill that formula to the bottom of the data (I have not pasted the vlookup line as it is irrelevant).
Cells(2, Range("A2").End(xlToRight).Column + 1).Select - This selects the first empty cell on row 2
*VLOOKUP FORMULA*
Selection.AutoFill Destination:=Range("B2:B" & Range("A" & Rows.Count).End(xlUp).Row)
Range(Selection, Selection.End(xlDown)).Select - This auto fills to the bottom of the data for the cell selected in step 1. However I can no longer use this as I need the range to be dynamic.
My problem is that the second line of code states cells "B2:B" but this won't always be the same range. I need this range to be the same as the one selected during the first line of code.
Is there anything I can add to the auto fill code, to always select the same range as the one selected in step 1, rather than always selecting column B (which was the first set of data ran)?
Thanks in advance.