+ Reply to Thread
Results 1 to 10 of 10

VBA code adjustment to include only current month and previous month automatically.

  1. #1
    Registered User
    Join Date
    08-24-2011
    Location
    Virginia
    MS-Off Ver
    Excel 2007
    Posts
    78

    VBA code adjustment to include only current month and previous month automatically.

    Need the code below to automatically include current month and previous month without having to change the code each month. Thanks!

    Please Login or Register  to view this content.
    Last edited by ElmerFud; 08-04-2015 at 08:17 AM.

  2. #2
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: VBA code adjustment to include only current month and previous month automatically.

    Hi Elmer

    Please wrap your Code in Code Tags.
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  3. #3
    Registered User
    Join Date
    08-24-2011
    Location
    Virginia
    MS-Off Ver
    Excel 2007
    Posts
    78

    Re: VBA code adjustment to include only current month and previous month automatically.

    Quote Originally Posted by jaslake View Post
    Hi Elmer

    Please wrap your Code in Code Tags.
    Sorry, I thought I did but one of the brackets was messed up.

  4. #4
    Forum Contributor
    Join Date
    08-16-2012
    Location
    Sydney
    MS-Off Ver
    Excel 2019
    Posts
    209

    Re: VBA code adjustment to include only current month and previous month automatically.

    Hi Elmer,

    have not tested yet on VBA, but you can use worksheetfunction.EoMonth.

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Let me know whether it work or not.

    Cheers
    Lex

  5. #5
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: VBA code adjustment to include only current month and previous month automatically.

    Hi Elmer

    Not tested...try this.
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    08-24-2011
    Location
    Virginia
    MS-Off Ver
    Excel 2007
    Posts
    78

    Re: VBA code adjustment to include only current month and previous month automatically.

    Quote Originally Posted by jaslake View Post
    Hi Elmer

    Not tested...try this.
    Please Login or Register  to view this content.

    Jaslake, That works great thanks! But for some reason it's not bringing over the right columns and rows for some reason. The range should be columns and rows pertaining to A thru F only. It's bringing over all columns and rows A thru I. Can you help with that?

  7. #7
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: VBA code adjustment to include only current month and previous month automatically.

    Hi Elmer

    Not without seeing your Workbook and just what it is you're trying to do.

    On the surface this line if Code makes no sense to me...your placing your Filter starting at Row 4298...
    Please Login or Register  to view this content.
    And yet you start the Copy of visible cells at Row 2...
    Please Login or Register  to view this content.
    Last edited by jaslake; 08-05-2015 at 01:08 PM.

  8. #8
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: VBA code adjustment to include only current month and previous month automatically.

    How can this work correctly ? (2 points before Autofilter)
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    08-24-2011
    Location
    Virginia
    MS-Off Ver
    Excel 2007
    Posts
    78

    Re: VBA code adjustment to include only current month and previous month automatically.

    Quote Originally Posted by jaslake View Post
    Hi Elmer

    Not without seeing your Workbook and just what it is you're trying to do.

    On the surface this line if Code makes no sense to me...your placing your Filter starting at Row 4298...
    Please Login or Register  to view this content.
    And yet you start the Copy of visible cells at Row 2...
    Please Login or Register  to view this content.
    Thanks again Jaslake, Yes, their demands here are never ending. Your right originally it transferred rows starting at ("$A$4298:$F$14000") to current but now their asking me to isolate automatically the most current month along with the last two years. So it's change yet again on me and I forgot to update the code and my question. What I'm trying to accomplish with my limited knowledge is to transfer Columns and Rows A thru F only for the current month and to also include the last two years.

  10. #10
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: VBA code adjustment to include only current month and previous month automatically.

    Hi Elmer

    You've got my knickers twisted. Attach your File...I'll look at it...

+ 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. [SOLVED] Formula for amount on previous month based on current month
    By Yu Marquez in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 02-21-2014, 12:42 AM
  2. [SOLVED] "copy worksheet from previous month and rename to current month" modified?
    By jerrydiaz in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-07-2013, 08:18 AM
  3. Macro using vlookups comparing 2 months paysheet(previous month and current month)
    By srinivasan1965 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-07-2012, 03:45 AM
  4. Replies: 5
    Last Post: 10-04-2012, 07:06 AM
  5. [SOLVED] VBA to identify the current month and previous month based on system date
    By ravikumar00008 in forum Excel General
    Replies: 10
    Last Post: 07-26-2012, 10:04 AM
  6. [SOLVED] copy worksheet from previous month and rename to current month
    By Dan E. in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-08-2005, 05:45 PM
  7. [SOLVED] automatically update chart plotting current month and previous 6
    By Jane in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 09-01-2005, 06:05 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