I can't get result run the macro

AT BABU

Board Regular
Joined
Oct 12, 2018
Messages
54
Office Version
  1. 2016
Platform
  1. Windows
Hi All,

I create below macro, Macro runing. but I cna't get result

Sub MyAutofilter()
Dim st As Long, en As Long
st = Range("s1").Value '''''''''assume this is the start date
en = Range("t1").Value ''''''assume this is the end date
Range("A1:I1").AutoFilter

ActiveSheet.Range("G2:G1500").AutoFilter Field:=7, Criteria1:= _
">=& st", Operator:=xlAnd, Criteria2:="<=& en"
End Sub
 
Last edited:

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Hi there. Try replacing
Code:
ActiveSheet.Range("G2:G1500").AutoFilter Field:=7, Criteria1:= _
        ">=& st", Operator:=xlAnd, Criteria2:="<=& en"
with
Code:
ActiveSheet.Range("G2:G1500").AutoFilter Field:=7, Criteria1:= _
        ">="& st, Operator:=xlAnd, Criteria2:="<="& en
 
Upvote 0

Forum statistics

Threads
1,223,104
Messages
6,170,125
Members
452,303
Latest member
c4cstore

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