+ Reply to Thread
Results 1 to 6 of 6

How to filter for previous month data only?

  1. #1
    Forum Contributor
    Join Date
    09-19-2016
    Location
    Alaska
    MS-Off Ver
    MS 2010, 2013, 2016
    Posts
    272

    How to filter for previous month data only?

    Hi everyone

    I have
    Please Login or Register  to view this content.
    in date criteria that seems to return only last months data. I found this through Google, so can someone verify that's all it does?

    Also, I'm somewhat familiar with functions in MAccess but never really spent time in learning the month/year functions. Can anyone explain to me how to write them or maybe give me a good link that shows me how to?
    Last edited by AccountingJ; 11-06-2020 at 09:40 AM.

  2. #2
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: How to filter for previous month data only?

    Here is the spec sheet on DateSerial.
    https://docs.microsoft.com/en-us/off...erial-function

    You can also search for Year, Month and Date vba functions on the web to get their spec sheets.

    The snippet in the OP simply returns values between last month and this month. Code can be written to set criteria based on number of days, > or < a specific date, etc. Depends on what the user needs.
    Any code provided by me should be tested on a copy or a mock up of your original data before applying it to the original. Some events in VBA cannot be reversed with the undo facility in Excel. If your original post is satisfied, please mark the thread as "Solved". To upload a file, see the banner at top of this page.
    Just when I think I am smart, I learn something new!

  3. #3
    Forum Contributor
    Join Date
    09-19-2016
    Location
    Alaska
    MS-Off Ver
    MS 2010, 2013, 2016
    Posts
    272

    Re: How to filter for previous month data only?

    what if I only wanted values for last month? and thanks for the link.

  4. #4
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: How to filter for previous month data only?

    Quote Originally Posted by AccountingJ View Post
    what if I only wanted values for last month? and thanks for the link.
    I think The line of code in the OP pretty much does that. If you are not getting the right resullt, try changing the zero in the second DateSerial function to a 1 and see if that improves the results. It does not hurt to try the codes you find. In most cases the worst that can happen is that it will throw an error or shut down, but you should be using a mock file or copy to do your testing, not your original file. Only apply code you get from the internet to your original after testing it on another file that will not matter if it crashes.

  5. #5
    Forum Contributor
    Join Date
    09-19-2016
    Location
    Alaska
    MS-Off Ver
    MS 2010, 2013, 2016
    Posts
    272

    Re: How to filter for previous month data only?

    Thank you, when I read that you said it pulls last month and this month I thought I would get data for November as well when I didn't want that to be returned.

  6. #6
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: How to filter for previous month data only?

    Quote Originally Posted by AccountingJ View Post
    Thank you, when I read that you said it pulls last month and this month I thought I would get data for November as well when I didn't want that to be returned.
    You're welcome,
    regards, JLG

+ 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. Macro code to filter for the end date of the previous month
    By yipdog in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-31-2020, 09:37 PM
  2. Filter Pivot by Previous Month
    By Oxygen Potassium in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-16-2019, 03:47 PM
  3. display previous month data
    By P13T3R L3 R0UX in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-11-2019, 05:12 AM
  4. Row calculation changes each month when data from previous month is deleted
    By SHOOTERTPP in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-03-2017, 01:32 AM
  5. Macro for applying filter for previous month's data
    By aaron1976 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 12-21-2015, 06:29 PM
  6. Filter for the previous month only - Pivot VBA (WITH ATTACHEMENT)
    By BrianBrian76 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-17-2015, 10:05 PM
  7. [SOLVED] Filter for the previous month only - Pivot VBA
    By BrianBrian76 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-15-2015, 05:12 AM

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