ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Copy down formula macro (https://www.excelbanter.com/excel-worksheet-functions/250600-copy-down-formula-macro.html)

Eva

Copy down formula macro
 
Hi
I have this macro that doesn't work and I am not sure why:

LastRow = Sheets("Sheet1").Range("D" & Rows.Count).End(xlUp).Row
Sheets("Sheet1").Range("P2:q2").Copy _
Destination:=Sheets("Sheet1").Range("P3:Q" & LastRow)
Calculate

Macro should check how many rows are in column D and then copy the formula
form P2:Q2 down to the last row.


--
Greatly appreciated
Eva

Mike H

Copy down formula macro
 
Hi,

In what way doesn't it work because it looks fine to me?

Mike

"Eva" wrote:

Hi
I have this macro that doesn't work and I am not sure why:

LastRow = Sheets("Sheet1").Range("D" & Rows.Count).End(xlUp).Row
Sheets("Sheet1").Range("P2:q2").Copy _
Destination:=Sheets("Sheet1").Range("P3:Q" & LastRow)
Calculate

Macro should check how many rows are in column D and then copy the formula
form P2:Q2 down to the last row.


--
Greatly appreciated
Eva


Gord Dibben

Copy down formula macro
 
Certainly works for me.

What does it not do for you?

Add a message box after this line

LastRow = Sheets("Sheet1").Range("D" & Rows.Count).End(xlUp).Row

msgbox Lastrow

What number is returned?


Gord Dibben MS Excel MVP

On Wed, 9 Dec 2009 12:51:37 -0800, Eva
wrote:

Hi
I have this macro that doesn't work and I am not sure why:

LastRow = Sheets("Sheet1").Range("D" & Rows.Count).End(xlUp).Row
Sheets("Sheet1").Range("P2:q2").Copy _
Destination:=Sheets("Sheet1").Range("P3:Q" & LastRow)
Calculate

Macro should check how many rows are in column D and then copy the formula
form P2:Q2 down to the last row.



Eva

Copy down formula macro
 
...Hm, I don't know what I did but it works now :) thanks
--
Greatly appreciated
Eva


"Mike H" wrote:

Hi,

In what way doesn't it work because it looks fine to me?

Mike

"Eva" wrote:

Hi
I have this macro that doesn't work and I am not sure why:

LastRow = Sheets("Sheet1").Range("D" & Rows.Count).End(xlUp).Row
Sheets("Sheet1").Range("P2:q2").Copy _
Destination:=Sheets("Sheet1").Range("P3:Q" & LastRow)
Calculate

Macro should check how many rows are in column D and then copy the formula
form P2:Q2 down to the last row.


--
Greatly appreciated
Eva



All times are GMT +1. The time now is 05:16 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com