Hi, I have a sheet with data (Sheet1) and I have a search sheet (Sheet2) where I can search the data from sheet1 and shows the results in sheet2 at the moment I do a search entering a batch number and what I need is to be able to do another search by entering the date. Can anyone help..
Private Sub Search_Click()
Dim itemcode As Variant, i As Long
Dim R As Range, f As Range, cell As String
itemcode = Sheet2.Range("c2").Value 'search box
If itemcode = "" Then
MsgBox "Please Enter The Batch number!"
Exit Sub
End If
Set R = Sheet1.Range("A:H") 'column range
Set f = R.Find(itemcode, LookIn:=xlValues, Lookat:=xlWhole)
If Not f Is Nothing Then
cell = f.Address
i = 5 'start in 5th row
Do
Sheet2.Range("A" & i).Resize(1, 8).Value = f.Resize(1, 8).Value
i = i + 1
Set f = R.FindNext(f)
Loop While Not f Is Nothing And f.Address <> cell
MsgBox "Search Complete"
Else
MsgBox "Batch number does not exist!"
End If
End Sub
Private Sub ClearSearch_Click()
Range("C2").ClearContents
Range("A5:H1000000").ClearContents
ActiveWindow.ScrollRow = 1
Range("C2").Select
End Sub
Private Sub PrintSearch_Click()
Application.CommandBars.ExecuteMso ("PrintPreviewAndPrint")
End Sub
This is sheet2 so what I need is to search for batch number on certain date.
Regards
Private Sub Search_Click()
Dim itemcode As Variant, i As Long
Dim R As Range, f As Range, cell As String
itemcode = Sheet2.Range("c2").Value 'search box
If itemcode = "" Then
MsgBox "Please Enter The Batch number!"
Exit Sub
End If
Set R = Sheet1.Range("A:H") 'column range
Set f = R.Find(itemcode, LookIn:=xlValues, Lookat:=xlWhole)
If Not f Is Nothing Then
cell = f.Address
i = 5 'start in 5th row
Do
Sheet2.Range("A" & i).Resize(1, 8).Value = f.Resize(1, 8).Value
i = i + 1
Set f = R.FindNext(f)
Loop While Not f Is Nothing And f.Address <> cell
MsgBox "Search Complete"
Else
MsgBox "Batch number does not exist!"
End If
End Sub
Private Sub ClearSearch_Click()
Range("C2").ClearContents
Range("A5:H1000000").ClearContents
ActiveWindow.ScrollRow = 1
Range("C2").Select
End Sub
Private Sub PrintSearch_Click()
Application.CommandBars.ExecuteMso ("PrintPreviewAndPrint")
End Sub
This is sheet2 so what I need is to search for batch number on certain date.
Regards