+ Reply to Thread
Results 1 to 10 of 10

Copying rows to another sheet based on date range

  1. #1
    Registered User
    Join Date
    08-29-2012
    Location
    Gold Coast, Queensland
    MS-Off Ver
    Excel 2003
    Posts
    5

    Copying rows to another sheet based on date range

    Hi there,

    I am really struggling with this one. We have a massive spreadsheet at work that contains 10 tabs that all have lots of data. We need to report on the newly added data each week and at the moment a staff member is finding and retyping this manually. I know we could filter and copy paste each tab but I would REALLY like a macro that would do this automatically when a date is entered into each of the tabs.

    What we need is if the date entered into one column on each sheet is within the past week, at least after a specified date that can be easily changed (at the moment I have a date entered on the "reporting" tab) that row is copied into the "reporting" tab. An additional challenge is that the date column is not the same on each tab. If this is a huge problem I could potentially move things around.

    I am pretty new to excel and have tried to work out formulas to do this and have had a play with macros but am failing miserably.

    I have attached a smaller version of our spreadsheet as a reference. It still has all 10 tabs and all the headings that are included.

    Any help would be greatly appreciated!
    Attached Files Attached Files
    Last edited by LSAILLARD; 09-03-2012 at 01:02 AM. Reason: retitle

  2. #2
    Registered User
    Join Date
    08-29-2012
    Location
    Gold Coast, Queensland
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: automatically copying rows to another sheet based on date range

    Can some body please help?!

  3. #3
    Registered User
    Join Date
    08-29-2012
    Location
    Gold Coast, Queensland
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: automatically copying rows to another sheet based on date range

    ok I have managed to create the below code which works but it copies all the lines instead of just the ones greater to or equal to the specified date.
    Can some one please let me know how to correct it please.

    Please Login or Register  to view this content.

  4. #4
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Copying rows to another sheet based on date range

    So you need a macro that checks each row in each sheet - if the date is greater than the date given in cell B1 of the reporting tab, the data should be shown below?

    However, your headers are not consistent between all the sheets. How do you want to handle that?
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  5. #5
    Registered User
    Join Date
    08-29-2012
    Location
    Gold Coast, Queensland
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Copying rows to another sheet based on date range

    Hi Arlette,

    Thank you for replying. I have re-jigged the example spreadsheet so that columns A-S are all exactly the same & have just hidden the unnecessary columns on each sheet. These are really the only columns that I need copied to the reporting sheet.

    That's right. If the date in Column L is greater than the date shown in B1 on the Reporting Sheet then copy the data in that row below.
    Basically we need to report on the jobs that have been completed in the past week. The date in B1 will change each time we run the report.

    I have reattached the exampleReplacement Product Register v3TEST.xlsm

  6. #6
    Registered User
    Join Date
    08-29-2012
    Location
    Gold Coast, Queensland
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Copying rows to another sheet based on date range

    Ok I have been working on this thing for ages now and below is the code I have now.
    I have been able to get the code to work with the findwhat function and if I enter the exact date I know is there it will copy to the reporting sheet. But it wont search all sheets.
    I have been playing with it to get it to work searching between dates and have the below code. Can some one please help as now I get a runtime error type mismatch on this line
    Please Login or Register  to view this content.
    Here is the whole code
    Please Login or Register  to view this content.
    Last edited by arlu1201; 09-08-2012 at 11:56 AM.

  7. #7
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Copying rows to another sheet based on date range

    Why are you using one variable for both the start date and end date? You will need to use 2 variables like this -

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    01-13-2017
    Location
    Phoenix, AZ
    MS-Off Ver
    Office 2013
    Posts
    2

    Re: Copying rows to another sheet based on date range

    Hi, I copied the code above and entered both FindWhat & FindWhat1, but this code still copies "all cells" with dates, instead of the range. Do I need to change this line of code to make it work: "If InStr(cell.Text, findWhat) <> 0 Then"? I notice this line has "findwhat", but doesn't have "findwhat1". Is there a proper way to add "findwhat1" into the code? Thank you!
    Last edited by Karate; 01-14-2017 at 07:41 PM.

  9. #9
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,675

    Re: Copying rows to another sheet based on date range

    Karate,
    Unfortunately your post does not comply with Rule 2 of our Forum RULES. Do not post a question in the thread of another member -- start your own thread.

    If you feel an existing thread is particularly relevant to your need, provide a link to the other thread in your new thread.

    Old threads are often only monitored by the original participants. New threads not only open you up to all possible participants again, they typically get faster response, too.



    Please, also post your workbook:


    (How to) Upload a Workbook directly to the Forum
    (please do not post pictures or links to worksheets)
    • Click Advanced next to Quick Post button at the bottom right of the editor box.
    • Scroll down until you see "Manage Attachments",
    • Click the "Choose" button at the upper left (upload from your computer).
    • Select your file, click "open", click "upload"
    • Once the upload is completed the file name will appear below the input boxes in this window.
    • Close the Attachment Manager window.
    • Click "Submit Reply"
    Note: Please do not attach password protected workbooks/worksheets
    Ensure to disable any Workbook Open/Autorun macros before attaching!
    Ben Van Johnson

  10. #10
    Registered User
    Join Date
    01-13-2017
    Location
    Phoenix, AZ
    MS-Off Ver
    Office 2013
    Posts
    2

    Re: Copying rows to another sheet based on date range

    How do I do that? My question pertains to the information in this thread. If I post my question in its own thread, the user will not be able to review the code and previous messages, and therefore understand my question.

    Thanks!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

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