View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.misc
Jacob Skaria Jacob Skaria is offline
external usenet poster
 
Posts: 8,520
Default Find Range Borders (Cell Addresses) In VBA

Oops. .modified to suit your requirement...

Function GetAddressString(varRange As Range) As String
Dim varTemp As Range

GetAddressString = GetAddressString & "," & _
Replace(varRange.Columns(1).Address, ":", ",")
If varRange.Columns.Count 1 Then
GetAddressString = GetAddressString & "," & _
Replace(varRange.Columns(varRange.Columns.Count).A ddress, ":", ",")
End If
GetAddressString = Mid(GetAddressString, 2)
End Function


If this post helps click Yes
---------------
Jacob Skaria


"FARAZ QURESHI" wrote:

Sorry Jacob,
But upon applying it on my data, i.e. X5:AC99, result is not as expected. It
comes to
$X$5,$X$99,$Y$5,$Y$99,$Z$5,$Z$99,$AA$5,$AA$99,$AB$ 5,$AB$99,$AC$5,$AC$99
?
?
?

"Jacob Skaria" wrote:

Paste the below function and call it as..

Msgbox "The active borders are " & GetaddressString(Range("A1:B10"))

Function GetAddressString(varRange As Range) As String
Dim varTemp As Range
For Each varTemp In varRange.Columns
GetAddressString = GetAddressString & "," & Replace(varTemp.Address, ":", ",")
Next
GetAddressString = Mid(GetAddressString, 2)
End Function
--
If this post helps click Yes
---------------
Jacob Skaria


"FARAZ QURESHI" wrote:

I have a selected range, say X5:AC99. What piece of code would return a msgbox:
"The active range borders a
$X$5, $AC$5, $X$99 & $AC$99"