Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Retrieving range string from named range

I have an input box that defines a range, which is then named, i.e. myRange.

Later in the program, I have need of the String version of the range that
the user entered.

To be specific, the following line of code DOES work:

Sheets(i).Range("k26:k48").Value = Sheets(1).Range("k26:k48").Value

However, the same line, using the SAME range, just in a named format, does
NOT work:

Sheets(i).Range("myRange").Value = Sheets(1).Range("myRange").Value

Does this make sense?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Retrieving range string from named range

If myrange is truly a range found in the listing in Insert=Names=Define

then
Dim rng as Range
set rng = Sheets(1).Range("MyRange")
Sheets(i).Range(rng.Address).Value = rng.Value

or

With Sheets(1).Range("MyRange")
Sheets(i).Range(.Address).Value = .Value
End With

--
Regards,
Tom Ogilvy


"clapper" wrote in message
...
I have an input box that defines a range, which is then named, i.e.

myRange.

Later in the program, I have need of the String version of the range that
the user entered.

To be specific, the following line of code DOES work:

Sheets(i).Range("k26:k48").Value = Sheets(1).Range("k26:k48").Value

However, the same line, using the SAME range, just in a named format, does
NOT work:

Sheets(i).Range("myRange").Value = Sheets(1).Range("myRange").Value

Does this make sense?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Retrieving range string from named range

Tom,

No, the range is not found in 'Names'-'Define'. The sheet is protected, so
all of that is greyed out.

Maybe I'm calling it the wrong thing. What I'm calling a 'named range' is
being created in the macro with the following code:

Dim ItemRange As Range
Set ItemRange = Application.InputBox(prompt:="Select Range of Items...",
Type:=8)

Does that shed any light on the issue?

"Tom Ogilvy" wrote:

If myrange is truly a range found in the listing in Insert=Names=Define

then
Dim rng as Range
set rng = Sheets(1).Range("MyRange")
Sheets(i).Range(rng.Address).Value = rng.Value

or

With Sheets(1).Range("MyRange")
Sheets(i).Range(.Address).Value = .Value
End With

--
Regards,
Tom Ogilvy


"clapper" wrote in message
...
I have an input box that defines a range, which is then named, i.e.

myRange.

Later in the program, I have need of the String version of the range that
the user entered.

To be specific, the following line of code DOES work:

Sheets(i).Range("k26:k48").Value = Sheets(1).Range("k26:k48").Value

However, the same line, using the SAME range, just in a named format, does
NOT work:

Sheets(i).Range("myRange").Value = Sheets(1).Range("myRange").Value

Does this make sense?




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Retrieving range string from named range

Yes, you have a variable of type Range which is referencing a specific set
of cells in a specific worksheet. So to use that:

Sheets(i).Range(ItemRange.Address).Value = ItemRange.Value

--
Regards,
Tom Ogilvy

"clapper" wrote in message
...
Tom,

No, the range is not found in 'Names'-'Define'. The sheet is protected,

so
all of that is greyed out.

Maybe I'm calling it the wrong thing. What I'm calling a 'named range' is
being created in the macro with the following code:

Dim ItemRange As Range
Set ItemRange = Application.InputBox(prompt:="Select Range of Items...",
Type:=8)

Does that shed any light on the issue?

"Tom Ogilvy" wrote:

If myrange is truly a range found in the listing in

Insert=Names=Define

then
Dim rng as Range
set rng = Sheets(1).Range("MyRange")
Sheets(i).Range(rng.Address).Value = rng.Value

or

With Sheets(1).Range("MyRange")
Sheets(i).Range(.Address).Value = .Value
End With

--
Regards,
Tom Ogilvy


"clapper" wrote in message
...
I have an input box that defines a range, which is then named, i.e.

myRange.

Later in the program, I have need of the String version of the range

that
the user entered.

To be specific, the following line of code DOES work:

Sheets(i).Range("k26:k48").Value = Sheets(1).Range("k26:k48").Value

However, the same line, using the SAME range, just in a named format,

does
NOT work:

Sheets(i).Range("myRange").Value = Sheets(1).Range("myRange").Value

Does this make sense?






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Retrieving range string from named range

That did it. Thanks!

"Tom Ogilvy" wrote:

Yes, you have a variable of type Range which is referencing a specific set
of cells in a specific worksheet. So to use that:

Sheets(i).Range(ItemRange.Address).Value = ItemRange.Value

--
Regards,
Tom Ogilvy

"clapper" wrote in message
...
Tom,

No, the range is not found in 'Names'-'Define'. The sheet is protected,

so
all of that is greyed out.

Maybe I'm calling it the wrong thing. What I'm calling a 'named range' is
being created in the macro with the following code:

Dim ItemRange As Range
Set ItemRange = Application.InputBox(prompt:="Select Range of Items...",
Type:=8)

Does that shed any light on the issue?

"Tom Ogilvy" wrote:

If myrange is truly a range found in the listing in

Insert=Names=Define

then
Dim rng as Range
set rng = Sheets(1).Range("MyRange")
Sheets(i).Range(rng.Address).Value = rng.Value

or

With Sheets(1).Range("MyRange")
Sheets(i).Range(.Address).Value = .Value
End With

--
Regards,
Tom Ogilvy


"clapper" wrote in message
...
I have an input box that defines a range, which is then named, i.e.
myRange.

Later in the program, I have need of the String version of the range

that
the user entered.

To be specific, the following line of code DOES work:

Sheets(i).Range("k26:k48").Value = Sheets(1).Range("k26:k48").Value

However, the same line, using the SAME range, just in a named format,

does
NOT work:

Sheets(i).Range("myRange").Value = Sheets(1).Range("myRange").Value

Does this make sense?






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
Join non-contiguous ranges into one range via named range? ker_01 Excel Discussion (Misc queries) 3 May 1st 09 11:09 AM
Referencing a named range based upon Range name entry in cell Barb Reinhardt Excel Worksheet Functions 14 June 20th 07 07:19 PM
automatic range - named range give me circular reference... George Thorogood Excel Discussion (Misc queries) 0 February 22nd 07 07:53 PM
If any cell in named range = 8 then shade named range JJ[_8_] Excel Programming 3 August 26th 05 11:09 PM
Setting named range in VBA- how to set as formula/reference instead of text string? Keith R[_3_] Excel Programming 1 July 28th 03 10:26 PM


All times are GMT +1. The time now is 09:38 PM.

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"