Excel GOTO

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need a GOTO macro. A number say "1001" is in cell A1. When I click on the
button, the macro references cell A1 and then takes the cursor to the cell
(in column A) that holds the value in A1.

joeski

----------------
This post is a suggestion for Microsoft, and Microsoft responds to the
suggestions with the most votes. To vote for this suggestion, click the "I
Agree" button in the message pane. If you do not see the button, follow this
link to open the suggestion in the Microsoft Web-based Newsreader and then
click "I Agree" in the message pane.

http://www.microsoft.com/office/com...2-e10c61c36bd1&dg=microsoft.public.excel.misc
 
Put a button from the Forms toolbar on the sheet (near A1???) and assign it this
macro:

Option Explicit
Sub testme()

Dim res As Variant
Dim myRng As Range

With ActiveSheet
Set myRng = .Range("a2", .Cells(.Rows.Count, "A").End(xlUp))
res = Application.Match(.Range("a1").Value, myRng, 0)
If IsError(res) Then
Beep 'not found
Else
Application.Goto myRng(res) ', scroll:=True
End If
End With
End Sub

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm
 
One way (attach this macro to your button):

Public Sub MyGOTO()
Dim rFound As Range
Set rFound = Columns(1).Find( _
What:=Range("A1").Value, _
After:=Range("A1"), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
MatchCase:=False)
If Not rFound.Row = 1 Then _
rFound.Select
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top