Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Macro to Define Range Name

Can anyone suggest how to create a macro to define and
update a range name in a worksheet each time the data
inreases or decreases? My range changes from time to time
and each time I have to manually define the range.

Thanks in advance.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Macro to Define Range Name

If the range is separated from everything else by at least one blank row top
and bottom and one blank column left and right, you can do

Range("MyName").CurrentRegion.Name = "MyName"

Or, for a single column Range

Dim rng as Range
set rng = Range("MyName")

Range(rng(1),rng(1).End(xldown)).Name = "MyName"


--
Regards,
Tom Ogilvy

"Phil" wrote in message
...
Can anyone suggest how to create a macro to define and
update a range name in a worksheet each time the data
inreases or decreases? My range changes from time to time
and each time I have to manually define the range.

Thanks in advance.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 107
Default Macro to Define Range Name

Tom,

If I can jump in here with a question I've been curious about for a
while now --

I have a couple of applications in which I use three or four dynamic
ranges (using OFFSET). These ranges form the basis for various filtering
operations, pivot tables, etc.

Is there a lot of overhead involved in these dynamic ranges? Are there
advantages to setting the range in code as in your code below? Or
disadvantages?

One disadvantage that immediately springs to mind is that the range
needs to be reset every time data is added to the table, but the dynamic
range automatically copes. I could get round this fairly easily, if I
had a reason to. Do I?

Thanks

--
Dianne

In ,
Tom Ogilvy typed:
If the range is separated from everything else by at least one blank
row top and bottom and one blank column left and right, you can do

Range("MyName").CurrentRegion.Name = "MyName"

Or, for a single column Range

Dim rng as Range
set rng = Range("MyName")

Range(rng(1),rng(1).End(xldown)).Name = "MyName"



"Phil" wrote in message
...
Can anyone suggest how to create a macro to define and
update a range name in a worksheet each time the data
inreases or decreases? My range changes from time to time
and each time I have to manually define the range.

Thanks in advance.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default Macro to Define Range Name

I don't know about how much overhead for the dynamic range names (but I don't
care either--my time is more important than a few extra megs of
memory/storage). I'll let excel be excel.

My feeling is that if I'm building the pivottable (for example) from scratch
each time I need it, I'll do it in code. (Like if I'm importing a text file and
doing summaries.) But if I know that the data/pivottable will be refreshed
manually, I'll use the dynamic ranges.



Dianne wrote:

Tom,

If I can jump in here with a question I've been curious about for a
while now --

I have a couple of applications in which I use three or four dynamic
ranges (using OFFSET). These ranges form the basis for various filtering
operations, pivot tables, etc.

Is there a lot of overhead involved in these dynamic ranges? Are there
advantages to setting the range in code as in your code below? Or
disadvantages?

One disadvantage that immediately springs to mind is that the range
needs to be reset every time data is added to the table, but the dynamic
range automatically copes. I could get round this fairly easily, if I
had a reason to. Do I?

Thanks

--
Dianne

In ,
Tom Ogilvy typed:
If the range is separated from everything else by at least one blank
row top and bottom and one blank column left and right, you can do

Range("MyName").CurrentRegion.Name = "MyName"

Or, for a single column Range

Dim rng as Range
set rng = Range("MyName")

Range(rng(1),rng(1).End(xldown)).Name = "MyName"



"Phil" wrote in message
...
Can anyone suggest how to create a macro to define and
update a range name in a worksheet each time the data
inreases or decreases? My range changes from time to time
and each time I have to manually define the range.

Thanks in advance.


--

Dave Peterson

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Macro to Define Range Name

I support the use of dynamic named ranges. Unless you find recalculations
are taking a long time, I wouldn't worry about them.

--
Regards,
Tom Ogilvy

"Dave Peterson" wrote in message
...
I don't know about how much overhead for the dynamic range names (but I

don't
care either--my time is more important than a few extra megs of
memory/storage). I'll let excel be excel.

My feeling is that if I'm building the pivottable (for example) from

scratch
each time I need it, I'll do it in code. (Like if I'm importing a text

file and
doing summaries.) But if I know that the data/pivottable will be

refreshed
manually, I'll use the dynamic ranges.



Dianne wrote:

Tom,

If I can jump in here with a question I've been curious about for a
while now --

I have a couple of applications in which I use three or four dynamic
ranges (using OFFSET). These ranges form the basis for various filtering
operations, pivot tables, etc.

Is there a lot of overhead involved in these dynamic ranges? Are there
advantages to setting the range in code as in your code below? Or
disadvantages?

One disadvantage that immediately springs to mind is that the range
needs to be reset every time data is added to the table, but the dynamic
range automatically copes. I could get round this fairly easily, if I
had a reason to. Do I?

Thanks

--
Dianne

In ,
Tom Ogilvy typed:
If the range is separated from everything else by at least one blank
row top and bottom and one blank column left and right, you can do

Range("MyName").CurrentRegion.Name = "MyName"

Or, for a single column Range

Dim rng as Range
set rng = Range("MyName")

Range(rng(1),rng(1).End(xldown)).Name = "MyName"



"Phil" wrote in message
...
Can anyone suggest how to create a macro to define and
update a range name in a worksheet each time the data
inreases or decreases? My range changes from time to time
and each time I have to manually define the range.

Thanks in advance.


--

Dave Peterson





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 107
Default Macro to Define Range Name

Tom and Dave,

I love my dynamic ranges (picked up the trick from Jan Karel back on the
old Compuserve Excel forums), but have been wondering whether I'm
putting an unnecessary strain on Excel in some way. Recalculations are
fine, so I'll leave them as is. I'm glad for the confirmation -- thanks!

--
Dianne

In ,
Tom Ogilvy typed:
I support the use of dynamic named ranges. Unless you find
recalculations are taking a long time, I wouldn't worry about them.


"Dave Peterson" wrote in message
...
I don't know about how much overhead for the dynamic range names
(but I don't care either--my time is more important than a few extra
megs of memory/storage). I'll let excel be excel.

My feeling is that if I'm building the pivottable (for example) from
scratch each time I need it, I'll do it in code. (Like if I'm
importing a text file and doing summaries.) But if I know that the
data/pivottable will be refreshed manually, I'll use the dynamic
ranges.



Dianne wrote:

Tom,

If I can jump in here with a question I've been curious about for a
while now --

I have a couple of applications in which I use three or four dynamic
ranges (using OFFSET). These ranges form the basis for various
filtering operations, pivot tables, etc.

Is there a lot of overhead involved in these dynamic ranges? Are
there advantages to setting the range in code as in your code
below? Or disadvantages?

One disadvantage that immediately springs to mind is that the range
needs to be reset every time data is added to the table, but the
dynamic range automatically copes. I could get round this fairly
easily, if I had a reason to. Do I?

Thanks

--
Dianne

In ,
Tom Ogilvy typed:
If the range is separated from everything else by at least one
blank row top and bottom and one blank column left and right, you
can do

Range("MyName").CurrentRegion.Name = "MyName"

Or, for a single column Range

Dim rng as Range
set rng = Range("MyName")

Range(rng(1),rng(1).End(xldown)).Name = "MyName"



"Phil" wrote in message
...
Can anyone suggest how to create a macro to define and
update a range name in a worksheet each time the data
inreases or decreases? My range changes from time to time
and each time I have to manually define the range.

Thanks in advance.


--

Dave Peterson



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Define Name range Gotroots Excel Discussion (Misc queries) 10 December 19th 09 11:30 AM
define max in range (macro) Steve Excel Discussion (Misc queries) 3 January 7th 09 01:55 AM
Define a range jlclyde Excel Discussion (Misc queries) 2 April 17th 08 08:26 PM
Macro - define cell range for a sum function Fad Excel Discussion (Misc queries) 2 June 6th 05 12:40 PM
Define a range based on another named range Basil Excel Worksheet Functions 2 February 21st 05 01:47 PM


All times are GMT +1. The time now is 06:35 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"