How to use VBA to find/go to a row

mike4

New Member
Joined
Mar 24, 2010
Messages
20
I am working on a sheet with 100+ rows of data, each row representing a different size of widgets. I have a cell at the top - Q1 - where you can enter the size widget you are looking for and, using conditional formatting, the row(s) containing that size widget will turn yellow with bold text.

What I'd like to do is add a button that would allow the user to go immediately to that row without having to scroll up/down to try and find it. My VBA skill set is limited and I'm having trouble getting something to work.

Any help would be appreciated!

Thanks.

Mike
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Since you could have more than one row matching the criteria, what should happen when the button is clicked in such an instance?
 
Upvote 0
you can use
Code:
Sub Findwidget()

Dim rFound As Range



    On Error Resume Next

    With ActiveSheet
        Set rFound = .Columns(1).Find(What:=.Range("Q1"), LookIn:=xlValues, LookAt:=xlWhole) 'change .Columns(1) to the column number you need to look in
    On Error GoTo 0

        If Not rFound Is Nothing Then Application.Goto rFound, True

    End With
End Sub
 
Last edited:
Upvote 0
Since you could have more than one row matching the criteria, what should happen when the button is clicked in such an instance?

All like size rows are sequential, so if it took the user to the first instance, all the others would be be immediately below it. I believe the greatest number of like-sized widgets is 4.

Thanks!

Mike
 
Upvote 0
Here is another macro for you to consider...

Rich (BB code):
Sub FindQ1Cell()
  On Error GoTo NotThere
  Columns("A").Find(Range("Q1").Value, LookAt:=xlWhole, MatchCase:=False).Select
  Exit Sub
NotThere:
  MsgBox "That widget does not appear to exist!", vbCritical
End Sub
Change my guess at your column's letter designation to the actual letter designation where your widgets are listed.
 
Upvote 0

Forum statistics

Threads
1,215,047
Messages
6,122,858
Members
449,096
Latest member
Erald

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top