1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Want to filter data for current month only

Discussion in 'Business Applications' started by sneha21, Oct 29, 2015.

Thread Status:
Not open for further replies.
  1. sneha21

    sneha21 Thread Starter

    Joined:
    Oct 29, 2015
    Messages:
    1
    Hi,

    My excel sheet contains data for different months.
    So I want that when I run the macro my excel sheet should be filtered such that it only shows the data for current month. The Date format in my sheet is "20110419".
     
  2. CDHarm

    CDHarm

    Joined:
    May 26, 2011
    Messages:
    255
    Hi,

    See if this code helps. It filters on the current month in column 2.

    Code:
    Sub Filter_Current_Month()
        ActiveSheet.Range("A1:d1").Select
            Selection.AutoFilter
            With Selection
                .AutoFilter Field:=2, Criteria1:=xlFilterThisMonth, Operator:=xlFilterDynamic
            End With
        Selection.AutoFilter
    End Sub
    
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/1158917

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice