ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macros and field names (https://www.excelbanter.com/excel-programming/419438-macros-field-names.html)

Joe

Macros and field names
 
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?

Per Jessen[_2_]

Macros and field names
 
Hi

Maybe this will help you:

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

Regards,
Per


On 3 Nov., 02:07, Joe wrote:
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?



ShaneDevenshire

Macros and field names
 
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.

--
Thanks,
Shane Devenshire


"Joe" wrote:

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?


Mike Fogleman[_2_]

Macros and field names
 
Perhaps it would be simpler to create a dynamic named range and let the
range adjust to the data size, so the code doesn't need to.

http://www.contextures.com/xlNames01.html#Dynamic

Mike F
"Joe" wrote in message
...
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?





All times are GMT +1. The time now is 02:57 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com