Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Hayfa Khan   on Aug 10 In MS Office Category.

  
Question Answered By: Hattie Howard   on Aug 10

I thought it was interesting coding to check for an address.... There may be
a function for it... Dunno really... Here's my effort..

Sub subGoToAddress()

Dim slAddy As String
Dim slAddyR1C1 As String
Dim slSheet As String
Dim slCell As String
Dim ilBang As Integer
Dim ilErrNum As Integer
Dim slTest As String
Dim ilN As Integer

' Pick up addresses.
slAddy = Selection.Formula ' R1C1
slAddyR1C1 = Selection.FormulaR1C1

' Is it a formula?
If Len(slAddy) > 1 Then

If Left(slAddy, 1) <> "=" Then
Exit Sub
End If

' Strip the "="
slAddy = Mid(slAddy, 2)
slAddyR1C1 = Mid(slAddyR1C1, 2)
Else
Exit Sub
End If

ilBang = InStr(slAddy, "!")
If ilBang = 0 Then

' No Sheet seperator found.
' Try and assume this one.
slSheet = ActiveSheet.Name
slCell = slAddy

Else

slSheet = Mid(slAddy, 1, ilBang - 1)
slCell = Mid(slAddy, ilBang + 1)

End If

If Len(slSheet) = 0 Then
Exit Sub
End If
If Len(slAddy) = 0 Then
Exit Sub
End If

' Try and see if it's a valid address.
slTest = Replace(slAddyR1C1, "+", "")
slTest = Replace(slTest, "-", "")
slTest = Replace(slTest, "]C[", "")
slTest = Replace(slTest, "RC[", "")
slTest = Replace(slTest, "R[", "")
slTest = Replace(slTest, "]C", "")
slTest = Replace(slTest, "]", "")
For ilN = 1 To 6500
slTest = Replace(slTest, CStr(ilN), "")
Next ilN

If Len(slTest) <> 0 Then
Exit Sub
End If

Sheets(slSheet).Activate
Range(slCell).Select

End Sub

Any other offers???

Share: 

 

This Question has 4 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on 2003 - Moving to a formula address Or get search suggestion and latest updates.


Tagged: