+ Reply to Thread
Results 1 to 3 of 3

Copying data based on current month of the year

  1. #1
    Forum Contributor
    Join Date
    03-14-2013
    Location
    England
    MS-Off Ver
    2007
    Posts
    191

    Copying data based on current month of the year

    Dear all,

    I am looking to build into a macro, a way for it to know what the current month of the year is. The idea is that it will find and copy sales data from a source workbook, to a target workbook containing a pre-arranged template, in order to create a sales analysis. I need to build into the macro a way for it to only copy this year's sales figures upto the end of the previous month, and always do this correctly at whatever time of the year it is run.

    I have put the code in below that I have so far which will find the lines for "AREA 1" in column A, "SALES" in column D, and the year in column F of the source data workbook and copy the required data across to the target workbook into the correct columns of the 2 sheets, for 2013 & 2014.

    I have attached the example I am using for the source data workbook and the target workbook, the below code exists as a macro within the target workbook entitled "Sales Analysis Template1.xlsm".

    What I want to do, is when coping the figures to the 2014 sheet, to exclude the months of the year that haven't occurred yet, including the current month. This needs to always work correctly at whatever time of the year the macro is run. So if we run it now, we want to end up with only Jan, Feb & March completed on the 2014 sheet, the rest of the monthly columns should be left blank.

    If anyone can help me out with this it would be much appreciated.

    Regards,

    Dave.





    Please Login or Register  to view this content.
    Attached Files Attached Files

  2. #2
    Forum Contributor
    Join Date
    04-24-2007
    Location
    NYC
    MS-Off Ver
    2k3/2k7/2010
    Posts
    270

    Re: Copying data based on current month of the year

    You can use Month() and Year(). Date will give you today's date. You can do stuff like Month(Date) and that will give you current month in number form.

  3. #3
    Forum Contributor
    Join Date
    03-14-2013
    Location
    England
    MS-Off Ver
    2007
    Posts
    191

    Re: Copying data based on current month of the year

    Yes I am aware of those functions for writing formulas in a cell. I have no idea how to write what I have described into the above code, I am looking for someone to show me an example of how to do that is it is possible.

    When finding the data in the source workbook that matches "AREA 1" in column A, "SALES" in column D, and "2014" in column F, I want to then identify how many of the columns from G-R are relevant now based on what month of the year it is, and then copy only those columns of data starting from G on the source workbook, and the pasted starting from column C on the target workbook. The columns that represent the months of the year that haven't occurred yet need to be left blank on the 2014 sheet, including the current month.

+ 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. Change year but keep the month the same based on current year
    By Jamon Fries in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 03-11-2014, 05:29 PM
  2. Replies: 3
    Last Post: 09-04-2013, 10:49 AM
  3. Replies: 1
    Last Post: 08-13-2012, 11:18 AM
  4. Current Year & Month Name, Previous Year & Month Name
    By mithesh in forum Excel General
    Replies: 9
    Last Post: 10-21-2011, 07:00 AM
  5. [SOLVED] Auto insert current month's name and current year
    By Webtekr in forum Word Formatting & General
    Replies: 0
    Last Post: 03-03-2009, 05:20 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