Fill formula down to last data row

J

juan

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
 
G

Guest

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
 
J

Juan

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 said:
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
.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top