I need an excel macro to name ranges

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a worksheet on which I have to name multiple ranges for another macro
I have created. The ranges aren't always the same size, however they always
start in column A and end in column U. I have been naming them by hand, but
when there are several hundred ranges, it takes a lot of time.
 
here is the code for nameing ranges

ActiveWorkbook.Names.Add Name:="Top50Rpt", RefersTo:= _
Range(Range("A1"),Range("A1").End(xlDown).offset(0, 3)

This selects a range from A1 to the end of the data in
column A and over 3 Columns. You can change the cell
reference and the offset to fit your ranges.
 
or more simply

Range(Range("A1"),Range("A1").End(xlDown).offset(0, 3)).Name:="Top50Rpt"


--

HTH

RP
(remove nothere from the email address if mailing direct)
 

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