M
Msgbox Data not found
Hi All,
I'm a baby to Excel Programming.
But I've to programme Excel 2003 work book in order that if sth is typed in
the text box control. The code searches all the worksheets and displays the
value in the label control.
I've a textbox control, label control and a command button control in Sheet 1
Now with the below mentioned codes I suceeded to retrieve a cell value in a
lable control. But the problem is, I've no idea to display all the cells
value of that from where the cell in a row, a data was retrieved.
Any Idea!!
Please Help!! SOS Please consider!!
Private Sub cmdbtn1_Click()
Dim Sh As Worksheet
Dim FoundIt As Boolean
d = "A1: A5000"
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"
Exit Sub
ElseIf Not b Is Nothing Then
firstAddress = b.Address
lbl1.Caption = b
Do
txtbx2.Value = c
Set b = .FindNext(b)
FoundIt = True
Loop While Not b Is Nothing And b.Address <> firstAddress
End If
End With
Next
If Not (FoundIt) Then
MsgBox "Data not found!!"
End If
End Sub
I'm a baby to Excel Programming.
But I've to programme Excel 2003 work book in order that if sth is typed in
the text box control. The code searches all the worksheets and displays the
value in the label control.
I've a textbox control, label control and a command button control in Sheet 1
Now with the below mentioned codes I suceeded to retrieve a cell value in a
lable control. But the problem is, I've no idea to display all the cells
value of that from where the cell in a row, a data was retrieved.
Any Idea!!
Please Help!! SOS Please consider!!
Private Sub cmdbtn1_Click()
Dim Sh As Worksheet
Dim FoundIt As Boolean
d = "A1: A5000"
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"
Exit Sub
ElseIf Not b Is Nothing Then
firstAddress = b.Address
lbl1.Caption = b
Do
txtbx2.Value = c
Set b = .FindNext(b)
FoundIt = True
Loop While Not b Is Nothing And b.Address <> firstAddress
End If
End With
Next
If Not (FoundIt) Then
MsgBox "Data not found!!"
End If
End Sub