Variable length named ranges

  • Thread starter Thread starter adimar
  • Start date Start date
A

adimar

I need a way to specify a variable for the last row in a named range.

A static definition looks like this:
ThisWorkbook.Names.Add Name:="dAge", RefersTo:="=RawData!$H$2:$H$100",
Visible:=True

I would like to replace “100†with “nRows†and need help with the syntax.


Thank you.
 
I assume that nRows is an integer or long variable...

ThisWorkbook.Names.Add Name:="dAge", RefersTo:="=RawData!$H$2:$H$" & nRows,
Visible:=True
 
In addition to other replies do you really mean to add the name to
"ThisWorkbook". From what you followed up with in your other recent I
suspect you mean ActiveWorkbook or some other named wb.

Regards,
Peter T
 

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