Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default 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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default 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

.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Filter data and fill only filtered data Thad Meyers[_2_] Excel Discussion (Misc queries) 1 August 30th 07 06:26 PM
Using Data Fill function to copy a Countif formula Rachael F Excel Worksheet Functions 0 March 8th 07 08:15 PM
Using Data Fill function to copy a Countif formula Duke Carey Excel Worksheet Functions 0 March 8th 07 06:38 PM
Fill formulas into adjacent cells does not take formula only data gnshort Excel Worksheet Functions 1 August 28th 06 11:41 PM
I have a list of data, fill in the gaps. FILL function won't work Triv Excel Discussion (Misc queries) 1 September 17th 05 02:33 PM


All times are GMT +1. The time now is 11:55 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"