Vb help

Posted on 2012-09-13
Last Modified: 2012-09-16
Please can you help,

I was hoping to amend the two command buttons so that they filter the page based on the dates held in B2:B3

At the moment it uses the filter function, but I was hoping to remove this. I just want to display the dates which fall between B2:B3 in column B
Question by:Kiwi-123
    LVL 23

    Expert Comment

    by:Christopher Kile
    If a date is to be removed, do you want to preserve the row it's in, or can that row be deleted?

    Author Comment

    I would like to preserve the row, or hide it.


    LVL 23

    Expert Comment

    by:Christopher Kile
    What is it that the filter function is doing that you don't want done?
    LVL 5

    Assisted Solution

    Add visibledropdown:=False

    wks.Range("$B$9:$B$1000").AutoFilter Field:=1, _
            Criteria1:=">=" & Format(wks.Range("B2").Value, "mm/dd/yyyy"), _
            Operator:=xlAnd, _
            Criteria2:="<" & Format(wks.Range("B3").Value + 1, "mm/dd/yyyy"), visibledropdown:=False
    LVL 23

    Expert Comment

    by:Christopher Kile
    Get rid of the named arguments; the named argument for VisibleDropDown did not seem to be acknowledged, but positional arguments work in this case:

    wks.Range("$B$9:$B$1000").AutoFilter 1, _
            ">=" & Format(wks.Range("B2").Value, "mm/dd/yyyy"), _
            xlAnd, _
            "<" & Format(wks.Range("B3").Value + 1, "mm/dd/yyyy"), _

    Open in new window

    LVL 23

    Accepted Solution

    Note: I tested this with your worksheet:

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Join & Write a Comment

    This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
    If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
    This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now