Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 102
Default Extending Named Ranges

I have 3 independent named ranges (e.g. they do not share any of the
same cells) and do not have any cells between them that are on the same
row - example:

range1 is from J9 to U15
range2 if from J20 to U23
range3 is from j25 to U50

the exact number of rows contained in each of these ranges will vary
from time to time.

I've added a custom menu that has three choices related to each range.
If the corresponding item is selected, I'd like to take the related
range,
insert a row below it, extend the named range to that row, and copy any
formating or formulas
to the added row.

For instance, if the .On Action for the first item were chosen,
I'd like it to insert a row below row 15, extend range1 from J9 to U16
and copy the formating and formulas from j15 through u15 to j16 through
u16.

If its selected again, it would add a row below 16, extend range1 from
j9 to u17, etc.

I've found a way to work with the cells when I know their
location/region, but not when I don't know the rows they inhabit - e.g.
making it more general.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Extending Named Ranges

Hi,

have a look at
http://www.contextures.com/xlNames01.html#Dynamic

-----Original Message-----
I have 3 independent named ranges (e.g. they do not

share any of the
same cells) and do not have any cells between them that

are on the same
row - example:

range1 is from J9 to U15
range2 if from J20 to U23
range3 is from j25 to U50

the exact number of rows contained in each of these

ranges will vary
from time to time.

I've added a custom menu that has three choices related

to each range.
If the corresponding item is selected, I'd like to take

the related
range,
insert a row below it, extend the named range to that

row, and copy any
formating or formulas
to the added row.

For instance, if the .On Action for the first item were

chosen,
I'd like it to insert a row below row 15, extend range1

from J9 to U16
and copy the formating and formulas from j15 through u15

to j16 through
u16.

If its selected again, it would add a row below 16,

extend range1 from
j9 to u17, etc.

I've found a way to work with the cells when I know their
location/region, but not when I don't know the rows they

inhabit - e.g.
making it more general.

.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Extending Named Ranges

Hi Marston,

One way:

Sub Tester()
Dim rng As Range

Set rng = Range("MyRangeName")

With rng.Rows
rng.Rows(.Count).Offset(1).EntireRow.Insert
rng.Rows(.Count).Copy rng.Rows(.Count).Offset(1)
rng.Resize(.Count + 1).Name = "MyRangeName"
End With

End Sub

---
Regards,
Norman



" wrote in message
oups.com...
I have 3 independent named ranges (e.g. they do not share any of the
same cells) and do not have any cells between them that are on the same
row - example:

range1 is from J9 to U15
range2 if from J20 to U23
range3 is from j25 to U50

the exact number of rows contained in each of these ranges will vary
from time to time.

I've added a custom menu that has three choices related to each range.
If the corresponding item is selected, I'd like to take the related
range,
insert a row below it, extend the named range to that row, and copy any
formating or formulas
to the added row.

For instance, if the .On Action for the first item were chosen,
I'd like it to insert a row below row 15, extend range1 from J9 to U16
and copy the formating and formulas from j15 through u15 to j16 through
u16.

If its selected again, it would add a row below 16, extend range1 from
j9 to u17, etc.

I've found a way to work with the cells when I know their
location/region, but not when I don't know the rows they inhabit - e.g.
making it more general.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Extending Named Ranges

Try something like

With Range("bob")
.Cells(.Rows.Count + 1, .Columns.Count).EntireRow.Insert
.Resize(.Rows.Count + 1, .Columns.Count).Name = "bob"
End With


--

HTH

RP

" wrote in message
oups.com...
I have 3 independent named ranges (e.g. they do not share any of the
same cells) and do not have any cells between them that are on the same
row - example:

range1 is from J9 to U15
range2 if from J20 to U23
range3 is from j25 to U50

the exact number of rows contained in each of these ranges will vary
from time to time.

I've added a custom menu that has three choices related to each range.
If the corresponding item is selected, I'd like to take the related
range,
insert a row below it, extend the named range to that row, and copy any
formating or formulas
to the added row.

For instance, if the .On Action for the first item were chosen,
I'd like it to insert a row below row 15, extend range1 from J9 to U16
and copy the formating and formulas from j15 through u15 to j16 through
u16.

If its selected again, it would add a row below 16, extend range1 from
j9 to u17, etc.

I've found a way to work with the cells when I know their
location/region, but not when I don't know the rows they inhabit - e.g.
making it more general.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 102
Default Extending Named Ranges

Thank Bob, Norman - both work perfectly.

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
extending named ranges chrisbmo2000 Excel Discussion (Misc queries) 2 May 5th 08 12:12 PM
Extending Look-up to multiple cell ranges sony654 Excel Worksheet Functions 4 April 5th 08 04:44 AM
named ranges Carol Ann Excel Worksheet Functions 4 February 4th 08 05:20 PM
Like 123, allow named ranges, and print named ranges WP Excel Discussion (Misc queries) 1 April 8th 05 06:07 PM
named ranges - changing ranges with month selected gr8guy Excel Programming 2 May 28th 04 04:50 AM


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

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

About Us

"It's about Microsoft Excel"