Macros and field names

J

Joe

I am extracting records, as part of a macro, from a list range on the
worksheet into a data named range. At times the source table will be
increased or decreased in size and when I run the macro I want it to resize
the extracted name range. How do I program this within the macro?
 
P

Per Jessen

Hi

Maybe this will help you:

NameRange = Range("A1", Range("A1").End(xlDown)).Address
ActiveWorkbook.Names.Add Name:="MyRangeName", RefersTo:="=Sheet1!" &
NameRange

Regards,
Per
 
S

ShaneDevenshire

Hi,

Suppose that the data is extracted to A1:D200

Range("A1").CurrentRegion.Name = "Database"

This assumes there is no data that is touching your extract that is not part
of the range you want to name.
 

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

Top