Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to get reference to a range as string?

I can get a reference to a cell as string with function CELL("address",
A1), which will return the string $A$1. How do I get a reference to a
range, for instance, A1:A5?

Thanks.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 236
Default How to get reference to a range as string?

Assuming you're taking about macros...
selection.address or range("A1:A5").address would produce a string of
$A$1:$A$5.
HTH,
Gary Brown



" wrote:

I can get a reference to a cell as string with function CELL("address",
A1), which will return the string $A$1. How do I get a reference to a
range, for instance, A1:A5?

Thanks.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to get reference to a range as string?

Thanks. I'm actualy writing it as a function, say Addr(range). It works
only for the range in the current sheet. If I enter Addr(Sheet2!A1:A5)
on a cell in Sheet1 , range.address only returns $A$1:$A$5 without the
sheet name. How do I write the Addr() so it adds the sheetname! only if
the input range is on another sheet.
Function Addr(r As Range)
Addr = r.Address
End Function

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 236
Default How to get reference to a range as string?

Function addr(r As Range) As String
Application.Volatile

If ActiveSheet.Name < r.Worksheet.Name Then
addr = r.Worksheet.Name & "!" & r.Address
Else
addr = r.Address
End If

End Function

hth,
Gary Brown


" wrote:

Thanks. I'm actualy writing it as a function, say Addr(range). It works
only for the range in the current sheet. If I enter Addr(Sheet2!A1:A5)
on a cell in Sheet1 , range.address only returns $A$1:$A$5 without the
sheet name. How do I write the Addr() so it adds the sheetname! only if
the input range is on another sheet.
Function Addr(r As Range)
Addr = r.Address
End Function


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
Can I show a reference value with a string? [email protected] Excel Discussion (Misc queries) 5 November 18th 05 08:31 PM
reference to a cell within a string susan hayes Excel Programming 3 September 29th 04 10:46 AM
Translate range name passed as string to a custom function to range addresses! agarwaldvk[_25_] Excel Programming 3 September 7th 04 12:47 PM
Passing a String in Array to Range as String [email protected] Excel Programming 2 September 1st 04 01:13 AM
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 07:04 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"