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: Adanalie Garcia   on Aug 10

Of course there's always the old error trapping way...

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

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

' Try and see if it's a valid address.
On Error Resume Next
Sheets(slSheet).Activate
ilErrNum = Err.Number
On Error GoTo 0
If ilErrNum <> 0 Then
Exit Sub
End If

Range(slCell).Select
ilErrNum = Err.Number
On Error GoTo 0

'
****************************************************************************
End Sub

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: