ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Copying to a flexible range (https://www.excelbanter.com/excel-discussion-misc-queries/176187-copying-flexible-range.html)

johncpa

Copying to a flexible range
 
I want to copy a formula using a macro but the ending part of the range can
change. For example, the user inputs the current age and a retirement age
and the retirement age can change. How do I create a macro that can allow
the range to be flexible, i.e. 15 years, 20 years, etc. I can copy the
formula manually to the ending range but I want to be able to have a macro
perform this automatically. Any help would be appreciated.

Don Guillett

Copying to a flexible range
 

lastrow=cells(rows.count,"a").end(xlup).row
range("b12").copy range("a"&lastrow)
--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"johncpa" wrote in message
...
I want to copy a formula using a macro but the ending part of the range can
change. For example, the user inputs the current age and a retirement age
and the retirement age can change. How do I create a macro that can allow
the range to be flexible, i.e. 15 years, 20 years, etc. I can copy the
formula manually to the ending range but I want to be able to have a macro
perform this automatically. Any help would be appreciated.




All times are GMT +1. The time now is 10:41 PM.

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