+ Reply to Thread
Results 1 to 6 of 6

VBA Code to Pull Data from a Sheet Based on Date and Add that Data to Another Sheet

  1. #1
    Registered User
    Join Date
    06-15-2014
    Location
    Cuthbert, Ga
    MS-Off Ver
    Office 2013
    Posts
    64

    VBA Code to Pull Data from a Sheet Based on Date and Add that Data to Another Sheet

    Here is another question for you geniuses here. I use my workbook to track sales data from one store to the next. I use my workbooks to compare data from year to year. Each year's data is displayed on a separate worksheet. '2013' has 2013's data, '2014' has 2014's. On the 2014 sheet, I have a Prior Year's Sales that pulls data from the previous year's spreadsheet using a formula which I just drag down each day I enter sales. I would like to automate this process and have the VBA code check for today's date and automatically pull the previous year's sales data from the '2013' sheet and put it in the appropriate cell on the '2014' worksheet. I hope I have explained this well enough to understand. I've included a link to my workbook for reference. Thank you in advance.

    I had to use dropbox since I can't post a file over 1 MB. The file size is around 1.25 MB.

    https://www.dropbox.com/s/w4g49ibab1...ortingWIP.xlsm
    Last edited by drsadistic; 08-09-2014 at 12:49 AM.

  2. #2
    Registered User
    Join Date
    09-13-2013
    Location
    Oakland, CA
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: VBA Code to Pull Data from a Sheet Based on Date and Add that Data to Another Sheet

    Why don't you just pull the formula all the way down to the end of the year now and your data will be filled going forward?

  3. #3
    Registered User
    Join Date
    06-15-2014
    Location
    Cuthbert, Ga
    MS-Off Ver
    Office 2013
    Posts
    64

    Re: VBA Code to Pull Data from a Sheet Based on Date and Add that Data to Another Sheet

    Quote Originally Posted by mooglebagel View Post
    Why don't you just pull the formula all the way down to the end of the year now and your data will be filled going forward?
    I have a table in my workbook that gives me an overview of my sales progress that is accurate upto the day. That helps me to manage my staff and supply better. If I pull the formula all the way down then my data become inaccurate for the period of time the data range covers.

  4. #4
    Registered User
    Join Date
    09-13-2013
    Location
    Oakland, CA
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: VBA Code to Pull Data from a Sheet Based on Date and Add that Data to Another Sheet

    What if you used the formula and copied down:

    =IF(B226<TODAY(),'2013'!C225,0)
    or
    =IF(B226<=TODAY(),INDEX('2013'!$C$4:$C$375,MATCH(DATE(YEAR(B226)-1,MONTH(B226),DAY(B226)),'2013'!$B$4:$B$375,0)),0)

    for example, in row 226. It would show zero values for dates after one year ago today and not affect any total calculations. Can code it in VBA but I'm not sure you need to.

  5. #5
    Registered User
    Join Date
    06-15-2014
    Location
    Cuthbert, Ga
    MS-Off Ver
    Office 2013
    Posts
    64

    Re: VBA Code to Pull Data from a Sheet Based on Date and Add that Data to Another Sheet

    You, my friend, are awesome! Thank you your first code was perfect. I don't know why I didn't think of that. Reputation added!

  6. #6
    Registered User
    Join Date
    09-13-2013
    Location
    Oakland, CA
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: VBA Code to Pull Data from a Sheet Based on Date and Add that Data to Another Sheet

    Glad it works. Thanks!

+ 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. Pull Data from Sheet Based on Criteria -- Populate UserForm & ask for Missing Data
    By roxybethany in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-15-2014, 12:08 PM
  2. Pull Data from Sheet Based on Criteria -- Populate UserForm & ask for Missing Data
    By roxybethany in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-08-2014, 02:05 PM
  3. Replies: 5
    Last Post: 07-23-2013, 01:17 PM
  4. Need Macro to pull data from one excel sheet to another based on a job# and comparing date
    By electromattnic in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-10-2013, 04:10 AM
  5. Macro code to pull data from different sheets based on the header of the main sheet
    By Shanthuday in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-21-2012, 05:00 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