ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Create a Named Range in Excel with VBA (https://www.excelbanter.com/excel-programming/318503-create-named-range-excel-vba.html)

GoKingBee

Create a Named Range in Excel with VBA
 
Hello Group:
I am attempting to create a named range in Excel by using a VBA macro. I
have a table of information where the number of rows is variable. I need to
create a hard coded range name by running a macro which will change as the
number of rows changes.

I attempted to record keystrokes, but am not getting the correct result.
Does anyone have any code they could share in this case?
thx
Bill

Frank Kabel

Create a Named Range in Excel with VBA
 
Hi
see:
http://www.xldynamic.com/source/xld.Names.html

--
Regards
Frank Kabel
Frankfurt, Germany

"GoKingBee" schrieb im
Newsbeitrag ...
Hello Group:
I am attempting to create a named range in Excel by using a VBA

macro. I
have a table of information where the number of rows is variable. I

need to
create a hard coded range name by running a macro which will change

as the
number of rows changes.

I attempted to record keystrokes, but am not getting the correct

result.
Does anyone have any code they could share in this case?
thx
Bill



Yoam69

Create a Named Range in Excel with VBA
 
If your table already has a range name (in my example "mytable"), then try
this piece of code

range("mytable").currentregion.name="mytable"

If the range doesn't exist yet, you need to add statements to set the active
cell to one within the range of interest, then continue with this code:

activecell.currentregion.name="mytable"

Substitue your named range as needed.

Rick Ward

"GoKingBee" wrote:

Hello Group:
I am attempting to create a named range in Excel by using a VBA macro. I
have a table of information where the number of rows is variable. I need to
create a hard coded range name by running a macro which will change as the
number of rows changes.

I attempted to record keystrokes, but am not getting the correct result.
Does anyone have any code they could share in this case?
thx
Bill



All times are GMT +1. The time now is 01:24 PM.

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