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

I need to dynamically define a range name based on the current monthly data
in a specified sheet. I would need to use the same range name multiple
times. I've tried the following (amoung others), but it doesn't seem to
work. Does anyone have any suggestions? Any help would be appreciated.

Sub Macro1()
'
Sheets("DataList").Select
Range("A1:H1").Select
Range(Selection, Selection.End(xlDown)).Select
Dim sAddress As String
sAddress = ActiveWindow.RangeSelection.Address


ActiveWorkbook.Names.Add Name:="rngTest",
RefersToR1C1:="=ActiveWindow.RangeSelection.Addres s"


End Sub

Thanks in advance.

Best Regards,

Wayne


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

Wayne

One way:

Dim sAddress As String
sAddress = Sheets("DataList").UsedRange.Address
ActiveWorkbook.Names.Add Name:="rngTest", _
RefersTo:="=DataList!" & sAddress

Or just:

ActiveWorkbook.Names.Add Name:="rngTest", _
RefersTo:="=DataList!" & _
Sheets("DataList").UsedRange.Address

Regards

Trevor


"Wayne Huxman" wrote in message
...
I need to dynamically define a range name based on the current monthly
data
in a specified sheet. I would need to use the same range name multiple
times. I've tried the following (amoung others), but it doesn't seem to
work. Does anyone have any suggestions? Any help would be appreciated.

Sub Macro1()
'
Sheets("DataList").Select
Range("A1:H1").Select
Range(Selection, Selection.End(xlDown)).Select
Dim sAddress As String
sAddress = ActiveWindow.RangeSelection.Address


ActiveWorkbook.Names.Add Name:="rngTest",
RefersToR1C1:="=ActiveWindow.RangeSelection.Addres s"


End Sub

Thanks in advance.

Best Regards,

Wayne




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

Hi Wayne,

Try:

Sub Macro1()
Dim rng As Range
Set rng = Sheets("Sheet1").Range("A1:H1")
Range(rng, rng.End(xlDown)).Name = "rngTest4"
End Sub


---
Regards,
Norman



"Wayne Huxman" wrote in message
...
I need to dynamically define a range name based on the current monthly
data
in a specified sheet. I would need to use the same range name multiple
times. I've tried the following (amoung others), but it doesn't seem to
work. Does anyone have any suggestions? Any help would be appreciated.

Sub Macro1()
'
Sheets("DataList").Select
Range("A1:H1").Select
Range(Selection, Selection.End(xlDown)).Select
Dim sAddress As String
sAddress = ActiveWindow.RangeSelection.Address


ActiveWorkbook.Names.Add Name:="rngTest",
RefersToR1C1:="=ActiveWindow.RangeSelection.Addres s"


End Sub

Thanks in advance.

Best Regards,

Wayne




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


Wayne,

Or you could try this:


Dim sAddress As String
Sheets("DataList").Select
Range("A1:H1").Select
Range(Selection, Selection.End(xlDown)).Select
sAddress = ActiveWindow.RangeSelection.Address
Range(sAddress).Name = "Sheet1!rngTest"




Charle

--
Charle
-----------------------------------------------------------------------
Charles's Profile: http://www.excelforum.com/member.php...nfo&userid=601
View this thread: http://www.excelforum.com/showthread.php?threadid=31919

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 a range jlclyde Excel Discussion (Misc queries) 2 April 17th 08 08:26 PM
Define a range based on another named range Basil Excel Worksheet Functions 2 February 21st 05 01:47 PM
Define Certain Exact Range sal21[_30_] Excel Programming 2 August 5th 04 02:25 PM
Define a Range depending on where the EOF is Dag Johansen[_5_] Excel Programming 5 September 23rd 03 03:45 AM


All times are GMT +1. The time now is 10:19 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"