How to grab a reference into VB

  • Thread starter Thread starter sb1920alk
  • Start date Start date
S

sb1920alk

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,
 
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.
 
"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.
 

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

Back
Top