Thread: Goto code
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Goto code

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Dim res As Variant
If Target.Address < "$D$3" Then Exit Sub
res = Application.Match(Target.Value, Me.Range("B:B"), 0)
If IsError(res) Then
'stay put
'beep '???
Else
Me.Range("B:B")(res).Select
End If
End Sub


Bob wrote:

I am using the following code to Goto the cell entered in cell "D3". It works
if there is a perfect match. If they do not match the code stops on line 3
with an error. What should be added to the code so that it will work when not
found and stay in cell "D3"? (With a pop of box "Number not Found" or
something like that)

The column has numbers like 4512 and 4512-1 and 4512-01 to match.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address < "$D$3" Then Exit Sub
Columns(2).Find(Target).Select
End Sub

Thank for your help,

Bob


--

Dave Peterson