R
Rose Tamang 2001
Dear Friends,
I've this code seaching sheets for a specific word and display it.
At this time the code accepts only a correct spellings. If wrong a msg box
is displayed. I want, that code should accept any two english alphabets typed
in the text box and display the result with words that contains two letters
Any idea!! Help!!
Private Sub cmdbtn1_Click()
Dim Sh As Worksheet
Dim FoundIt As Boolean
Set DestSht = Sheets("Main")
NewRow = 12
d = "B4: B5000"
'e = "B1:B5000"
Let c = txtbx1.Value
For Each Sh In ActiveWorkbook.Worksheets
With Sh.Range(d)
Set b = .Find(c, LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows)
If c = "" Then
MsgBox "You haven't typed anything in the Search Box" & vbNewLine &
"Contact:US", , "Help!!"
Exit Sub
ElseIf Not b Is Nothing Then
firstAddress = b.Address
lbl1.Caption = b
Do
Sh.Range("B" & b.Row & ":H" & b.Row).Copy Destination:=DestSht.Range("B" &
NewRow)
DestSht.Range("A" & NewRow) = Sh.Name
NewRow = NewRow + 1
FoundIt = True
Set b = .FindNext(after:=b)
Loop While Not b Is Nothing And b.Address <> firstAddress
End If
End With
Next
If FoundIt = False Then
MsgBox "Data not found!!", , "Sorry!!"
End If
End Sub
Private Sub cmdbtn2_Click()
lbl1.Caption = ""
txtbx1.Value = ""
LastRow = Rows.Count
Rows("12:" & LastRow).Delete
End Sub
I've this code seaching sheets for a specific word and display it.
At this time the code accepts only a correct spellings. If wrong a msg box
is displayed. I want, that code should accept any two english alphabets typed
in the text box and display the result with words that contains two letters
Any idea!! Help!!
Private Sub cmdbtn1_Click()
Dim Sh As Worksheet
Dim FoundIt As Boolean
Set DestSht = Sheets("Main")
NewRow = 12
d = "B4: B5000"
'e = "B1:B5000"
Let c = txtbx1.Value
For Each Sh In ActiveWorkbook.Worksheets
With Sh.Range(d)
Set b = .Find(c, LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows)
If c = "" Then
MsgBox "You haven't typed anything in the Search Box" & vbNewLine &
"Contact:US", , "Help!!"
Exit Sub
ElseIf Not b Is Nothing Then
firstAddress = b.Address
lbl1.Caption = b
Do
Sh.Range("B" & b.Row & ":H" & b.Row).Copy Destination:=DestSht.Range("B" &
NewRow)
DestSht.Range("A" & NewRow) = Sh.Name
NewRow = NewRow + 1
FoundIt = True
Set b = .FindNext(after:=b)
Loop While Not b Is Nothing And b.Address <> firstAddress
End If
End With
Next
If FoundIt = False Then
MsgBox "Data not found!!", , "Sorry!!"
End If
End Sub
Private Sub cmdbtn2_Click()
lbl1.Caption = ""
txtbx1.Value = ""
LastRow = Rows.Count
Rows("12:" & LastRow).Delete
End Sub