ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Assigning name to current region (https://www.excelbanter.com/excel-programming/337866-assigning-name-current-region.html)

KDJ

Assigning name to current region
 
Hello

After selecting the current region, I would like to assign the name
Total_Statistic. The region can change and the name should be overwritten
each time I run the macro.

I am selecting the region as follows:

Set tbl = ActiveCell.CurrentRegion
tbl.Select

I can't find the right VBA command to assign a name, given that this isn't a
cell reference. Would really appreciate some help!
--
Thanks very much. KDJ

Norman Jones

Assigning name to current region
 

Hi KDJ,

Try something like:

Public Sub Tester03a()
Dim tbl As Range

Set tbl = ActiveCell.CurrentRegion()

ActiveWorkbook.Names.Add _
Name:="Total_Statistic", _
RefersTo:=tbl
End Sub

---
Regards,
Norman



"KDJ" wrote in message
...
Hello

After selecting the current region, I would like to assign the name
Total_Statistic. The region can change and the name should be overwritten
each time I run the macro.

I am selecting the region as follows:

Set tbl = ActiveCell.CurrentRegion
tbl.Select

I can't find the right VBA command to assign a name, given that this isn't
a
cell reference. Would really appreciate some help!
--
Thanks very much. KDJ




KDJ

Assigning name to current region
 
Thanks again, Norman ... you've saved my Monday

KDJ


"Norman Jones" schrieb:


Hi KDJ,

Try something like:

Public Sub Tester03a()
Dim tbl As Range

Set tbl = ActiveCell.CurrentRegion()

ActiveWorkbook.Names.Add _
Name:="Total_Statistic", _
RefersTo:=tbl
End Sub

---
Regards,
Norman



"KDJ" wrote in message
...
Hello

After selecting the current region, I would like to assign the name
Total_Statistic. The region can change and the name should be overwritten
each time I run the macro.

I am selecting the region as follows:

Set tbl = ActiveCell.CurrentRegion
tbl.Select

I can't find the right VBA command to assign a name, given that this isn't
a
cell reference. Would really appreciate some help!
--
Thanks very much. KDJ






All times are GMT +1. The time now is 04:18 AM.

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