jmac121233
New Member
- Joined
- Oct 18, 2010
- Messages
- 5
I've searched existing threads but haven't had much luck finding the answer I need.
I have a formula in cell B2 that I'm trying to copy across all columns (with data in Row 1) and down all rows (with data in Column A). The number of rows and columns is going to be constantly changing (for example, this week I may need to copy B2 from B2:G50, but next week it may be B2:J100). I've figured out how to copy the formula down every row, but cannot figure out how to copy the formula across all columns. Any help would be greatly appreciated!! Macro code is provided below:
Also, much less importantly, is there a way to make my vlookup range dynamic as well?
Sheets("One").Select
Range("B2").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = _
"=VLOOKUP(RC1,Data!R3C1:R33C17,HLOOKUP(R1C,Data!R1C1:R2C17,2,FALSE),FALSE)"
Range("B2").Select
Selection.AutoFill Destination:=Range("B2:B" & Range("A" & Rows.Count).End(xlUp).Row)
I have a formula in cell B2 that I'm trying to copy across all columns (with data in Row 1) and down all rows (with data in Column A). The number of rows and columns is going to be constantly changing (for example, this week I may need to copy B2 from B2:G50, but next week it may be B2:J100). I've figured out how to copy the formula down every row, but cannot figure out how to copy the formula across all columns. Any help would be greatly appreciated!! Macro code is provided below:
Also, much less importantly, is there a way to make my vlookup range dynamic as well?
Sheets("One").Select
Range("B2").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = _
"=VLOOKUP(RC1,Data!R3C1:R33C17,HLOOKUP(R1C,Data!R1C1:R2C17,2,FALSE),FALSE)"
Range("B2").Select
Selection.AutoFill Destination:=Range("B2:B" & Range("A" & Rows.Count).End(xlUp).Row)