Search Enggine with Criteria Between 2 date Using VBA

andrianocaras

New Member
Joined
Jan 25, 2016
Messages
4
hello right now i was making a search enggine using VBA
with sheet 1 as database and sheet 2 as search enggine i have code like this :

my code is search enggine that search a data that contain an alphabet or number where the data being search anyone can change this so that the criteria for searching is between 2 date

Sub Seartch()
Dim sCol As String
Dim rgFind As Range, rgData As Range, rgCell As Range
Dim iCol As Integer
Dim lRow As Long
Dim vCrit As Variant

Sheet2.Range(Sheet2.Range("b9"), Sheet2.Range("b9").End(xlToRight).End(xlDown)).ClearContents
sCol = Sheet2.Range("c2").Value
Set rgFind = Sheet1.Range("a17:s17").Find(sCol, lookat:=xlWhole, MatchCase:=True)
iCol = rgFind.Column
lRow = Sheet1.Range("a17").CurrentRegion.Rows.Count
vCrit = Sheet2.Range("c4").Value
Set rgData = Sheet1.Range(Sheet1.Cells(18, iCol), Sheet1.Cells(lRow, iCol))
For Each rgCell In rgData
Set rgFind = rgCell.Find(vCrit, lookat:=xlPart, MatchCase:=False)
If Not rgFind Is Nothing Then
Sheet1.Range(Sheet1.Cells(rgCell.Row, 1), Sheet1.Cells(rgCell.Row, 19)).Copy
Sheet2.Cells(Sheet2.Rows.Count, 2).End(xlUp).Offset(1).PasteSpecial xlPasteValuesAndNumberFormats
Application.CutCopyMode = False
End If
Next rgCell
Range("c4").Select
End Sub
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)

Forum statistics

Threads
1,223,264
Messages
6,171,081
Members
452,377
Latest member
bradfordsam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top