+ Reply to Thread
Results 1 to 7 of 7

VBA Code to Filter dates with command button

  1. #1
    Registered User
    Join Date
    07-31-2013
    Location
    Wanganui New Zealand
    MS-Off Ver
    Excel 2010
    Posts
    23

    VBA Code to Filter dates with command button

    Hi

    Can anyone give me a simple VBA code to filter dates with a command button

    I have a worksheet and I want to use a command button to:

    ""Only show rows that have Jan 13 in Column G"" ( 01/01/13 - 31/01/13)

    Then once I have used information I want to push the button again and all rows return to sheet

    Thanks

    Angela

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,882

    Re: VBA Code to Filter dates with command button

    Attach a sample workbook. Make sure there is just enough data to make it clear what is needed. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are demonstrated, mock them up manually if needed. Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Registered User
    Join Date
    07-31-2013
    Location
    Wanganui New Zealand
    MS-Off Ver
    Excel 2010
    Posts
    23

    Re: VBA Code to Filter dates with command button

    Hi
    I found this code that works if I use a number in the 4th to last line but if I put a date in the line it doesn't work can someone give me a fix for 4th to last line

    Please Login or Register  to view this content.
    Moderator Note:

    Pls use code tags around your code next time as per forum rules.
    Last edited by Fotis1991; 10-11-2013 at 05:29 AM.

  4. #4
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: VBA Code to Filter dates with command button

    hi Angela, option, please check attachment, press Filter button

    PS. You need to use special tags for posing VB code on the forum. See Forum Rules for details
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    07-31-2013
    Location
    Wanganui New Zealand
    MS-Off Ver
    Excel 2010
    Posts
    23

    Re: VBA Code to Filter dates with command button

    Hi

    Sorry about the tags will do from now on.

    This works perfect, if I want to filter different month what do I change on the code (say only show Oct 13) Hide all other months
    Also how do I add the command button to this code I tried putting it in a command button code and it didn't work

    Angela

  6. #6
    Registered User
    Join Date
    07-31-2013
    Location
    Wanganui New Zealand
    MS-Off Ver
    Excel 2010
    Posts
    23

    Re: VBA Code to Filter dates with command button

    Hi

    I have worked out both issues thanks for a great code

    Angela

  7. #7
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: VBA Code to Filter dates with command button

    Based on your last post in this thread, its apparent that you are satisfied with the solution(s) you've received and have solved your question, but you haven't marked your thread as "SOLVED",as per our Forum Rule #9. I will do it for you this time.

    In future, to mark your thread as Solved, you can do the following -
    Select Thread Tools-> Mark thread as Solved.

    Incase your issue is not solved, you can undo it as follows -
    Select Thread Tools-> Mark thread as Unsolved.

    Also, since you are relatively new to the forum, i would like to inform you that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post which helped you. This adds to the reputation of the person who has taken the time to help you.
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Create a command button with code with a command button
    By jakara in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-29-2013, 01:28 PM
  2. Code for a master command button to change the backcolor of multiple command buttons?
    By panttherm5 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-16-2012, 10:11 PM
  3. [SOLVED] vba code, command bar, command bar button, one button works but not two
    By amazingg64 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-13-2012, 09:55 AM
  4. Trying to Give New Command Button Code from Another Sheet's Code
    By MegaRush in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-10-2012, 09:43 AM
  5. Data filter with command button
    By vba-lover in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-07-2007, 12:43 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1