+ Reply to Thread
Results 1 to 6 of 6

VBA Code needed to match a date and then copy a range and paste values

  1. #1
    Registered User
    Join Date
    08-15-2015
    Location
    Sydney, Australia
    MS-Off Ver
    2013
    Posts
    18

    VBA Code needed to match a date and then copy a range and paste values

    Hi,
    I am useless with VBA and was wondering if someone could assist with the following:

    I have created a rudimentary Fortnightly Staff Roster, with a corresponding time sheet page for each of my 30 staff members.

    1. At the end of each work week I select 'Yes' (drop down list) in column B of each sheet for that week;
    2. This then searches the ROSTER sheet, return's the staff member's rostered hours for each day of that week, and calculates total hours worked, gross pay, tax etc.
    3. After this i have to copy the cells from columns C to AO for that week-ending row and Paste Special>Values. This is needed because each fortnight the Roster sheet is changed to reflect the upcoming fortnight.

    I have a very simple macro that will do the copy and paste but i currently have to select the cell (where the macro should start) on each and every of the 30 worksheets.

    I was wondering if there is a way to have a macro that would do the following:

    1. Find the matching date row in each sheet (based on sheet Roster!G23);
    2. Copy the corresponding range from that row (columns C:AO);
    3. and Paste Special > Values onto the same range.

    for each of the 30 staff worksheets.

    I have attached a sample of the file.

    thanks in advance.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,525

    Re: VBA Code needed to match a date and then copy a range and paste values

    Hi ettamucci (and fellow Sydneyite ),

    Try this:

    Please Login or Register  to view this content.
    Regards,

    Robert
    ____________________________________________
    Please ensure you mark your thread as Solved once it is. Click here to see how
    If this post helps, please don't forget to say thanks by clicking the star icon in the bottom left-hand corner of my post

  3. #3
    Registered User
    Join Date
    08-15-2015
    Location
    Sydney, Australia
    MS-Off Ver
    2013
    Posts
    18

    Re: VBA Code needed to match a date and then copy a range and paste values

    Hi Robert,
    Absolute LEGEND!!!

    Could I please be a pain, but I forgot to mention it previously. I also needed it to change the corresponding value in Column B from 'No' to 'Yes' so that it can populate the row with data before the copy and paste.

    i am not sure if this would work though or whether it would have to be a separate macro that is run first.

    thank you again.

  4. #4
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,525

    Re: VBA Code needed to match a date and then copy a range and paste values

    Could I please be a pain, but I forgot to mention it previously. I also needed it to change the corresponding value in Column B from 'No' to 'Yes' so that it can populate the row with data before the copy and paste.
    No problem - try this:

    Please Login or Register  to view this content.
    Note I've also included code to exclude the Data tab.

    Regards,

    Robert

  5. #5
    Registered User
    Join Date
    08-15-2015
    Location
    Sydney, Australia
    MS-Off Ver
    2013
    Posts
    18

    Re: VBA Code needed to match a date and then copy a range and paste values

    Thanks again Robert.

    Love your work!!

  6. #6
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,525

    Re: VBA Code needed to match a date and then copy a range and paste values

    You're welcome. Thanks for marking the thread as solved and for the rep

+ 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 needed to copy/paste Range
    By jmisti2 in forum Excel Programming / VBA / Macros
    Replies: 24
    Last Post: 05-29-2014, 04:01 PM
  2. [SOLVED] INDEX date that MATCH on date range, MATCH code(string)
    By Dahlia in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-23-2014, 03:33 AM
  3. Macro needed: match names in different columns; then copy and paste range
    By msmith7113 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-08-2013, 11:56 AM
  4. Check if Date is in Range, Copy row values and paste into new sheet
    By learning123 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-12-2012, 03:11 PM
  5. Code to add a new row if needed when I paste a range in from another sheet
    By firerast in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-20-2011, 04:27 AM
  6. VBA code for copy/paste logic needed
    By overlook1977 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-05-2008, 10:20 PM
  7. VBA Code needed to copy and paste the format
    By deepikabalaji in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-19-2007, 05:15 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