+ Reply to Thread
Results 1 to 7 of 7

Need help- macro to scan all sheets for cells in date range, then copy rows to new sheet

  1. #1
    Registered User
    Join Date
    03-15-2016
    Location
    Iowa, USA
    MS-Off Ver
    2013
    Posts
    4

    Post Need help- macro to scan all sheets for cells in date range, then copy rows to new sheet

    I’m new to VBA and this site and while I’ve found code on macros similar to this, I’ve been unable to customize them for my specific needs or cobble several together and have them work with Excel 2013. (I hate to ask for help, but truth be told, I’ve a LOT of learning materials to work through before I can master the current task -- outlined below --on my own!)
    My need: Automate the monthly process of determining what corporate forms need to be updated based on date.
    My source file: I’ve a workbook composed of 16 worksheets. Each sheet contains info about all the forms used by a different department (ie., there’s a sheet listing QC’s forms, another for IT’s forms). Each sheet lists the forms by row. There are anywhere from 4-16 columns in each sheet, but I am only interested in columns A through G (1-7) for this project; column G will always be the one with the needed date.
    My Goal: a button click will prompt users to enter a beginning and end date. Then the macro would scan column G in EVERY sheet in the workbook to find dates falling in that range. Whenever found, the macro would copy columns A through G (1-7) in the row and paste them into an new sheet called “Report”, starting on row 2, columns B-H (2-8). We can assume all other worksheets are numbered in consecutive order, Sheet1, Sheet2, etc.
    An example:
    macro-help.jpg
    I'd thought about including details about what I'd already tried, but at this point my head is spinning and I think I need to start fresh.
    So, until I get “up to speed” with Excel VBA macros, I’d appreciate any help I can get with this.
    Thanks!
    BrenFred
    Last edited by BrenFred; 03-16-2016 at 07:31 PM. Reason: Substituted a text example with image

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,887

    Re: Need help- macro to scan all sheets for cells in date range, then copy rows to new she

    Since you did not provide a worksheet to test this code with, this is an untested code.

    Advise as necessary

    Please Login or Register  to view this content.
    If this does not work for you, then provide a sample workbook uploaded for analysis.
    Last edited by alansidman; 03-16-2016 at 07:59 PM.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Registered User
    Join Date
    03-15-2016
    Location
    Iowa, USA
    MS-Off Ver
    2013
    Posts
    4

    Re: Need help- macro to scan all sheets for cells in date range, then copy rows to new she

    Thanks for taking a stab at this. Your code looks so much simpler than anything I tried.
    When run, the error I get is this: Object variable or With block variable not set
    I'm trying to attach a sample workbook with a mock-up of my spreadsheet

    Thanks again,

    BrenFred
    Attached Files Attached Files

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,887

    Re: Need help- macro to scan all sheets for cells in date range, then copy rows to new she

    Revised code

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    03-15-2016
    Location
    Iowa, USA
    MS-Off Ver
    2013
    Posts
    4

    Re: Need help- macro to scan all sheets for cells in date range, then copy rows to new she

    Thanks for the revised code. When running the macro, I'm now getting a different error message: Subscript out of range.
    Any thoughts?

  6. #6
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,887

    Re: Need help- macro to scan all sheets for cells in date range, then copy rows to new she

    Create a new sheet called Report and then run the code.

  7. #7
    Registered User
    Join Date
    03-15-2016
    Location
    Iowa, USA
    MS-Off Ver
    2013
    Posts
    4

    Thumbs up Re: Need help- macro to scan all sheets for cells in date range, then copy rows to new she

    That worked ... originally I was thinking the macro would create the sheet Report, but this is better.
    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. macro to scan each column and reproduce specific cells to different sheet
    By scano.ie in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-06-2015, 07:22 PM
  2. Copy dynamic specified, filtered cells/range from one sheet to multiple sheets
    By szeconku in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-22-2015, 06:14 AM
  3. Replies: 5
    Last Post: 12-15-2014, 05:43 AM
  4. Macro to copy rows based on moving date and paste the rows into an identical sheet
    By ivandc1234 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-28-2014, 11:59 AM
  5. Use VBA to scan and copy rows from worksheets with criteria met to a summary sheet
    By nuttyengineer in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-31-2011, 05:28 PM
  6. copy cells from sheets based on date, paste to another sheet
    By upod in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 10-27-2009, 01:29 PM
  7. Copy Rows In New Sheet Based On Date Range Criteria
    By ahmedwaseem2000 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-10-2006, 05:45 AM

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