Please help me guys : )

yeongkwe

New Member
Joined
Dec 13, 2016
Messages
13
Hi, someone can kindly help me to solve this issue. I use the VBA code to filter the dates. I did some changes on the code, can anyone tell me did I do anything wrong? Because after I modify it, the search got no result coming out. Please kindly soul help me, and your help will be very much appreciated. Thanks you.

Sub Macro1()

abcd = Worksheets("sheet1").Cells(1, 101)
Range("A38:E38").Select
Selection.AutoFilter
ActiveSheet.Range("$A$38:$E$97375").AutoFilter Field:=5, Criteria1:= _
"<abcd", Operator:=xlAnd
End Sub


Below is original code before I modify.

Sub Macro1()
'
' Macro1 Macro
' w
'
' Keyboard Shortcut: Ctrl+w
'

Range("A38:E38").Select
Selection.AutoFilter
ActiveSheet.Range("$A$38:$E$97375").AutoFilter Field:=5, Criteria1:= _
"<15/08/2016", Operator:=xlAnd
End Sub
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
First of all below is the posters original code which didn't post correctly because of the < symbol being treated as Html code.

Code:
Sub Macro1()

abcd = Worksheets("sheet1").Cells(1, 101)
    Range("A38:E38").Select
    Selection.AutoFilter
    ActiveSheet.Range("$A$38:$E$97375").AutoFilter Field:=5, Criteria1:= _
        "<abcd", Operator:=xlAnd
End Sub


@ yeongkwe, Try...

Code:
Sub Macro1()
Dim abcd As Long
abcd = CLng(Worksheets("sheet1").Cells(1, 101))
   Range("A38:E38").AutoFilter
   Range("$A$38:$E$97375").AutoFilter Field:=5, Criteria1:= _
        "<" & abcd, Operator:=xlAnd
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,992
Messages
6,175,832
Members
452,674
Latest member
psion2600

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