i have been stuck on this for the last 3 days :'( im trying to find a value in column A:A starting with A2 and search for a match in column A across all the workshets in the active workbook (the number of work sheets vary depending on the wb) and when the value is found on whichever worksheet return the corresponding value from column K, i cant seem to make the code work and ive tried a couple different ways over the last few days, nothing is working please help :'(
Sub search()
Dim wkb As Workbook
Dim ws As Worksheet
Dim Cell As Range
Dim FoundCell As Range
On Error Resume Next
Set Cell = Range("a2").Value
With wkb
For Each ws In wkb.Worksheets
Set FoundCell = ws.Cells.Find(what:=Cell.Value, _
LookIn:=xlValues, Lookat:=xlWhole, MatchCase:=False)
If Not FoundCell Is Nothing Then
Cell.Offset(, 10).Value = FoundCell.Row
Exit Sub
End If
Next ws
On Error GoTo 0
End With
End Sub
Sub search()
Dim wkb As Workbook
Dim ws As Worksheet
Dim Cell As Range
Dim FoundCell As Range
On Error Resume Next
Set Cell = Range("a2").Value
With wkb
For Each ws In wkb.Worksheets
Set FoundCell = ws.Cells.Find(what:=Cell.Value, _
LookIn:=xlValues, Lookat:=xlWhole, MatchCase:=False)
If Not FoundCell Is Nothing Then
Cell.Offset(, 10).Value = FoundCell.Row
Exit Sub
End If
Next ws
On Error GoTo 0
End With
End Sub