willwill88
New Member
- Joined
- Dec 8, 2011
- Messages
- 5
I'm working on a VBA that will autofill a formula (cell C3) based on the last row in column B, and last column in row 2.
The number of rows and columns is dynamic, however the formula will always be in C3.
This part works... but it only fills the first row and column:
LastCol = Range("C2").End(xlToRight).Column
LastRow = Range("B3").End(xlDown).Row
Debug.Print LastRow, LastCol
Range("C3").AutoFill Destination:=Range("C3", Cells(3, LastCol)), Type:=xlFillDefault
Range("C3").Select
Range("C3").Select
Selection.AutoFill Destination:=Range("C3:C" & Range("B1000000").End(xlUp).Row), Type:=xlFillDefault
I tried using the code below to fill the entire "rectangle" but I'm getting an error:
Range("C3").AutoFill Destination:=Range(Cells(LastRow, 3), Cells(3, LastCol)), Type:=xlFillDefault
Any ideas on how I can make this work???
Thanks!
The number of rows and columns is dynamic, however the formula will always be in C3.
This part works... but it only fills the first row and column:
LastCol = Range("C2").End(xlToRight).Column
LastRow = Range("B3").End(xlDown).Row
Debug.Print LastRow, LastCol
Range("C3").AutoFill Destination:=Range("C3", Cells(3, LastCol)), Type:=xlFillDefault
Range("C3").Select
Range("C3").Select
Selection.AutoFill Destination:=Range("C3:C" & Range("B1000000").End(xlUp).Row), Type:=xlFillDefault
I tried using the code below to fill the entire "rectangle" but I'm getting an error:
Range("C3").AutoFill Destination:=Range(Cells(LastRow, 3), Cells(3, LastCol)), Type:=xlFillDefault
Any ideas on how I can make this work???
Thanks!