![]() |
Fill formula down to last data row
Hello All,
I have following code: Dim Lastrow As Long Lastrow = ActiveSheet.Cells(Rows.Count, "A").End (xlUp).Row Worksheets("TEST1").Select Range("O1").Select ActiveCell.FormulaR1C1 = "=OFFSET(RC[-14],0,R1C16)" Range("O1:O" & Lastrow).Filldown Worksheets("TEST2").Select Range("O1").Select ActiveCell.FormulaR1C1 = "=OFFSET(RC[-14],0,R1C16)" Range("O1:O" & Lastrow).Filldown The first sheet does seem to work but the second sheet it fills down only to the 8 row, which in the first sheet that's how far data goes. So I need to fill the formula down to last data row of each sheet. Please advise with any help. thank you, Juan |
Fill formula down to last data row
Juan
When switching to the second sheet you need to recalculate your Lastrow variable i.e repeat the line: Lastrow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row Rowan "juan" wrote: Hello All, I have following code: Dim Lastrow As Long Lastrow = ActiveSheet.Cells(Rows.Count, "A").End (xlUp).Row Worksheets("TEST1").Select Range("O1").Select ActiveCell.FormulaR1C1 = "=OFFSET(RC[-14],0,R1C16)" Range("O1:O" & Lastrow).Filldown Worksheets("TEST2").Select Range("O1").Select ActiveCell.FormulaR1C1 = "=OFFSET(RC[-14],0,R1C16)" Range("O1:O" & Lastrow).Filldown The first sheet does seem to work but the second sheet it fills down only to the 8 row, which in the first sheet that's how far data goes. So I need to fill the formula down to last data row of each sheet. Please advise with any help. thank you, Juan |
Fill formula down to last data row
Hello Rowan,
thanks for the info. Works now. Juan -----Original Message----- Juan When switching to the second sheet you need to recalculate your Lastrow variable i.e repeat the line: Lastrow = ActiveSheet.Cells(Rows.Count, "A").End (xlUp).Row Rowan "juan" wrote: Hello All, I have following code: Dim Lastrow As Long Lastrow = ActiveSheet.Cells(Rows.Count, "A").End (xlUp).Row Worksheets("TEST1").Select Range("O1").Select ActiveCell.FormulaR1C1 = "=OFFSET(RC[-14],0,R1C16)" Range("O1:O" & Lastrow).Filldown Worksheets("TEST2").Select Range("O1").Select ActiveCell.FormulaR1C1 = "=OFFSET(RC[-14],0,R1C16)" Range("O1:O" & Lastrow).Filldown The first sheet does seem to work but the second sheet it fills down only to the 8 row, which in the first sheet that's how far data goes. So I need to fill the formula down to last data row of each sheet. Please advise with any help. thank you, Juan . |
All times are GMT +1. The time now is 09:20 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com