Find a value in a workbook and activate that cell

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
In a workbook or in a worksheet?

In a worksheet is relatively easy
In all the worksheets of a workbook is also not too difficult
finding the values in a chart sheet could be harder

do you just want the 1st occurance (define how to find first: worksheets, rows, columns), all occrances or a count

Do you want to do this for a single value or for many values (it could get slow if you have a lot of them)
 
Upvote 0
Try:

Code:
Sub Test()
    Const LookFor As String = "abc"
    Dim Sh As Worksheet
    Dim rng As Range
    For Each Sh In ActiveWorkbook.Worksheets
        With Sh
            Set rng = .Cells.Find(What:=LookFor, After:=.Cells(.Cells.Count), LookIn:=xlValues, LookAt:= _
                xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
                , SearchFormat:=False)
            If Not rng Is Nothing Then
                    Application.Goto rng, True
                Exit Sub
            End If
        End With
    Next Sh
End Sub

Change LookFor to suit.
 
Upvote 0
.Cells(.Cells.Count) gives me an error of "Overflow"

Also I replaced it with ActiveCell it does not work.
It is searching for the the "valu" but not activating the cell

For Each Sh In ActiveWorkbook.Worksheets
With Sh
Set rng = .Cells.Find(What:=valu, After:=.Cells(.Cells.Count), LookIn:=xlValues, LookAt:= _
xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
, SearchFormat:=False)
If Not rng Is Nothing Then
Application.Goto rng, True
Exit Sub
End If
End With
Next Sh
 
Upvote 0
I tweeked the macro a little, go the solution

For Each Sh In ActiveWorkbook.Worksheets
With Sh
Set rng = .Cells.Find(What:=valu, After:=ActiveCell.Offset(-1, 0), LookIn:=xlValues, LookAt:= _
xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
, SearchFormat:=False)
If Not rng Is Nothing Then
Application.Goto rng, True


Exit For
End If
End With
Next Sh
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,286
Members
452,902
Latest member
Knuddeluff

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