Your posted code should only be searching column A. What makes you think it
is doing something else... Perhaps post some more code.
--
HTH...
Jim Thomlinson
- Show quoted text -
Here is the Code im using, I have 3 sheets,If i were to put the name
fry, Mcdonald in column A, and fry, BurgerKing in column B when it
pulls up the listbox both show, though only 1 should be showing..
Private Sub CmdSearch_Click()
Dim sh As Worksheet
Dim StrRng As Range
Dim StrSearching As String
Dim Found As Integer
Found = 0
StrSearching = TxtCaseName.Text
If TxtCaseName.Text = "" Then
GoTo ErrorHandler
End If
For Each sh In ThisWorkbook.Worksheets
sh.Activate
Set StrRng = sh.Columns(1).Find(What:=StrSearching,
After:=Columns.Range("A5"), LookIn:=xlFormulas, LookAt:=xlPart,
SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False)
IntNumber = MySearch(StrRng)
If IntNumber > 0 Then
Found = Found + 1
End If
Next sh
If Found > 0 Then
Unload Me
FrmSelection.Show
Else
Unload Me
FCreate.Show
End If
ErrorHandler:
MsgBox "Please Type a Name", vbInformation, " No Names found"
End Sub
Function MySearch(StrRng As Range)
Dim firstAddress As String
Dim IntNumber As Integer
IntNumber = 0
If Not StrRng Is Nothing Then
firstAddress = StrRng.Address
MySearch = IntNumber + 1
Do
Set StrRng = Cells.FindNext(StrRng)
FrmSelection.LboxSelect.AddItem (StrRng)
Loop While Not StrRng Is Nothing And StrRng.Address <>
firstAddress
Else
MySearch = IntNumber
End If
End Function