L
L. Howard
Trying to convert this code to sheet 1 only, one column only (col T) and list all dupes in a msgbox with cell.address.
The search item could be for a number or text.
Thanks.
Howard
Sub FindSheetsWithID()
'/ code by Garry
' Looks for an ID on all sheets except "Sheet1",
' and notifies the result of the search.
Dim ws As Worksheet, Rng As Range
Dim sID$, sIdShts$, sMsg$
Dim bFoundID As Boolean
sID = InputBox("Enter a Client ID number")
If Trim(sID) = "" Then Exit Sub
For Each ws In ThisWorkbook.Worksheets
If Not ws.Name = "Sheet1" Then
Set Rng = ws.UsedRange.Find(What:=sID, _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByColumns)
If Not Rng Is Nothing Then
bFoundID = True
sIdShts = sIdShts & ",'" & ws.Name & "'!" & Rng.Address
End If
End If
Next ws
If bFoundID Then
sMsg = "The ID (" & sID & ") was found on the following sheets:"
sMsg = sMsg & vbLf & vbLf
sMsg = sMsg & Join(Split(Mid(sIdShts, 2), ","), vbLf)
Else
sMsg = "ID not found"
End If
MsgBox sMsg
End Sub
The search item could be for a number or text.
Thanks.
Howard
Sub FindSheetsWithID()
'/ code by Garry
' Looks for an ID on all sheets except "Sheet1",
' and notifies the result of the search.
Dim ws As Worksheet, Rng As Range
Dim sID$, sIdShts$, sMsg$
Dim bFoundID As Boolean
sID = InputBox("Enter a Client ID number")
If Trim(sID) = "" Then Exit Sub
For Each ws In ThisWorkbook.Worksheets
If Not ws.Name = "Sheet1" Then
Set Rng = ws.UsedRange.Find(What:=sID, _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByColumns)
If Not Rng Is Nothing Then
bFoundID = True
sIdShts = sIdShts & ",'" & ws.Name & "'!" & Rng.Address
End If
End If
Next ws
If bFoundID Then
sMsg = "The ID (" & sID & ") was found on the following sheets:"
sMsg = sMsg & vbLf & vbLf
sMsg = sMsg & Join(Split(Mid(sIdShts, 2), ","), vbLf)
Else
sMsg = "ID not found"
End If
MsgBox sMsg
End Sub