+ Reply to Thread
Results 1 to 9 of 9

Loop through dates and copy/paste Saturdays and Sundays to another work sheet

  1. #1
    Registered User
    Join Date
    05-10-2013
    Location
    Manitoba, Canada
    MS-Off Ver
    2010
    Posts
    28

    Loop through dates and copy/paste Saturdays and Sundays to another work sheet

    My data includes data for everything that has occurred through the week.

    I'm building a Pivotreport using Weekend Data only. The pivot is no problem. My problem is looping through the dates in column A of my "Data" worksheet and copying the row of data to a worksheet called "WkEndData"
    if the date is a Saturday or Sunday. I'm getting a mismatch error on my "IF" statement. There must be an easy way to move the "weekend Data" to another sheet. Any thoughts?


    Please Login or Register  to view this content.

  2. #2
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Loop through dates and copy/paste Saturdays and Sundays to another work sheet

    Jeep56,

    Does your data have headers? You are starting with cell A1 and if it is a header and not a date or date expression you would get the type mismatch error.
    Hope that helps,
    ~tigeravatar

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  3. #3
    Registered User
    Join Date
    07-15-2013
    Location
    New York
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: Loop through dates and copy/paste Saturdays and Sundays to another work sheet

    The issue is with your second argument "A" in the .cells() function call. It needs to be in numeric form or just 1 to refer to column A. .cells function accepts both numeric parameters like .cells(iRowNumber,iColumnNumber)

  4. #4
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Loop through dates and copy/paste Saturdays and Sundays to another work sheet

    @arunm1008, That is not correct. The Cells method will accept column letters as well as column numbers. You can test it out by using:
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    07-15-2013
    Location
    New York
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: Loop through dates and copy/paste Saturdays and Sundays to another work sheet

    Thanks tigeravatar

  6. #6
    Registered User
    Join Date
    05-10-2013
    Location
    Manitoba, Canada
    MS-Off Ver
    2010
    Posts
    28

    Re: Loop through dates and copy/paste Saturdays and Sundays to another work sheet

    Hi All, I've been out of office. Yes, I do have a Header row. I will change the code to see if that works.

  7. #7
    Registered User
    Join Date
    05-10-2013
    Location
    Manitoba, Canada
    MS-Off Ver
    2010
    Posts
    28

    Re: Loop through dates and copy/paste Saturdays and Sundays to another work sheet

    This works for Data with a Sunday(1) date but stalls on Saturday(7). It copy/pastes the first line of Saturday Data and ends sub. I'm not sure why
    ?

    Please Login or Register  to view this content.

  8. #8
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Loop through dates and copy/paste Saturdays and Sundays to another work sheet

    delete the Exit For line...

  9. #9
    Registered User
    Join Date
    05-10-2013
    Location
    Manitoba, Canada
    MS-Off Ver
    2010
    Posts
    28

    Re: Loop through dates and copy/paste Saturdays and Sundays to another work sheet

    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. Include Saturdays and maybe Sundays?
    By lil_ern63 in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 06-12-2008, 11:38 AM
  2. counting days excluding saturdays and sundays
    By p_dhoke in forum Excel General
    Replies: 2
    Last Post: 04-24-2007, 04:34 AM
  3. [SOLVED] Calculate the number of Saturdays or Sundays between 2 dates?
    By Jim Long in forum Excel General
    Replies: 1
    Last Post: 11-01-2005, 04:09 PM
  4. Need number of Saturdays and number of Sundays between 2 dates
    By Class316 in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 09-06-2005, 07:05 AM
  5. Subtract Dates excluding Saturdays and Sundays
    By Shirley Munro in forum Excel General
    Replies: 2
    Last Post: 01-14-2005, 06:26 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