How to grab a reference into VB
I have a macro that publishes a sheet as a webpage in the range "$A$1:$K$56"
but I'd like to change it to "$A$1:$K$**" instead where the ** number is pulled from a cell, say P1 based on the result of a formula in P1 because I have to manually change the macro every time the number of rows changes. Is that possible? Thanks, |
How to grab a reference into VB
you should be able to use:
Range("A1:K" & Range("P1").Value) assuming you are working with the activesheet. otherwise qualify the range references with the proper worksheet references. "sb1920alk" wrote: I have a macro that publishes a sheet as a webpage in the range "$A$1:$K$56" but I'd like to change it to "$A$1:$K$**" instead where the ** number is pulled from a cell, say P1 based on the result of a formula in P1 because I have to manually change the macro every time the number of rows changes. Is that possible? Thanks, |
How to grab a reference into VB
"A1:K" & Range("P1").Value is what worked, I kept getting an error with
Range("A1:K" & Range("P1").Value) Thanks for pointing me in the right direction. "JMB" wrote: you should be able to use: Range("A1:K" & Range("P1").Value) assuming you are working with the activesheet. otherwise qualify the range references with the proper worksheet references. "sb1920alk" wrote: I have a macro that publishes a sheet as a webpage in the range "$A$1:$K$56" but I'd like to change it to "$A$1:$K$**" instead where the ** number is pulled from a cell, say P1 based on the result of a formula in P1 because I have to manually change the macro every time the number of rows changes. Is that possible? Thanks, |
All times are GMT +1. The time now is 01:23 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com