How to add a Message box in a Macro which uses Auto-filter in Excel

Hi Guys, I wish to amend this macro so it selects an Autofilter in an Excel spreadsheet and then selects
a date in a column defined by what I input into a message box. How do I do this? In the code below, I have recorded a Macro which filters in Column G for the rows prior to 07/09/2015, but I wish to input a different date every week into a Message box so it does the same. I enclose the spreadsheet with Macro.

      Selection.AutoFilter
    ActiveSheet.Range("$A$1:$AF$8461").AutoFilter Field:=7, Criteria1:= _
        "<07/09/2015", Operator:=xlAnd
Commentary-Analysis.xlsm
JustinFinancial ControlAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rgonzo1971Commented:
Hi,

pls try
Sub Macro1()
'
' Macro1 Macro
'

'
    Sheets("All trades").Select
    Rows("1:1").Select
    Selection.AutoFilter
    ActiveSheet.Range("$A$1:$AF$80000").AutoFilter Field:=4, Criteria1:=Array( _
        "IRS", "Loan", "SCF", "SCF Adjustment"), Operator:=xlFilterValues
    Rows("2:2").Select
    Range(Selection, Selection.End(xlDown)).Select
    Selection.Delete Shift:=xlUp
    Rows("1:1").Select
    Selection.AutoFilter
    Selection.AutoFilter
    strDate = Application.InputBox("Enter A Date")
    If IsDate(strDate) Then
        ActiveSheet.Range("$A$1:$AF$8461").AutoFilter Field:=7, Criteria1:= _
        "<" & strDate, Operator:=xlAnd
    Else
        MsgBox "Invalid date"
    End If
    
End Sub

Open in new window

Regards

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
[ fanpages ]IT Services ConsultantCommented:
Hi,

Do you simply wish to enter a date into an Input Box, use the value in cell [C9] of the [Macros] worksheet, or automatically use a date based on whatever day (of the month/year) the button is clicked?

PS. I would also suggest using a format like [Dd-Mmm-YYYY] (i.e. 07-Sep-2015) to avoid confusion with the transposition of the day/month values; 09-Jul-2015, for example.
JustinFinancial ControlAuthor Commented:
Hi, I am trying to use this code to delete trades in between 07th Sep 2015 and 14th Sep 2015 using the Message box  but its not working any ideas?

    Sheets("All trades").Select
    Rows("1:1").Select
    Selection.AutoFilter
    strdate = Application.InputBox("please delete all trades between which dates?")

   
    ActiveSheet.Range("$A$1:$AF$111584").AutoFilter Field:=6, Criteria1:= _
        ">=" & strdate, Operator:=xlAnd
          strdate1 = Application.InputBox("please delete all trades between which dates?")
    ActiveSheet.Range("$A$1:$AF$111584").AutoFilter Field:=7, Criteria1:= _
        "<=" & strdate1, Operator:=xlAnd
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.