+ Reply to Thread
Results 1 to 7 of 7

vba copy and paste based on multiple loop criteria

  1. #1
    Registered User
    Join Date
    04-05-2013
    Location
    Little Rock, Ar
    MS-Off Ver
    Excel 2007
    Posts
    4

    vba copy and paste based on multiple loop criteria

    Hello I really need some help with my coding in Excel 2007.
    I have 80 worksheets in my workbook. I am trying to evaluate each sheet so that if there is a "Y" in a certain range of worksheets ("M" for Monday), then that sheet's data will be pasted to the sheet that begins with P (for prior week). There are 10 of these PW1, PW2, etc.
    Please Login or Register  to view this content.
    the code fails on the ElseIf line.
    Last edited by Leith Ross; 04-18-2013 at 01:54 PM. Reason: Added Code Tags

  2. #2
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591

    Re: vba copy and paste based on multiple loop criteria

    Hi

    ws1 is not assigned anywhere.

    rylo

  3. #3
    Registered User
    Join Date
    04-05-2013
    Location
    Little Rock, Ar
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: vba copy and paste based on multiple loop criteria

    Well Rylo, I'm not sure what you mean. I have ws1 setup in the Dim statement and the Elseif line. Do you have any suggestions as to how else to assign it?

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: vba copy and paste based on multiple loop criteria

    Hello sarahcpa,

    Welcome to the Forum!

    The statement Dim ws1 As Worksheet creates a Worksheet Object variable. You must assign that object variable to an existing worksheet.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  5. #5
    Registered User
    Join Date
    04-05-2013
    Location
    Little Rock, Ar
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: vba copy and paste based on multiple loop criteria

    I'm still stumped. Tried to change the code up a bit, but now I'm getting "end if without block If" error.
    pleeeeeease someone help me you guys seem to think I know what I'm doing.

    Please Login or Register  to view this content.

  6. #6
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591

    Re: vba copy and paste based on multiple loop criteria

    Hi

    Between your 2 end if statements, put in a next Dest. You haven't completed the for loop.

    rylo

  7. #7
    Registered User
    Join Date
    04-05-2013
    Location
    Little Rock, Ar
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: vba copy and paste based on multiple loop criteria

    YAY
    between your comments and more testing of individual pieces, I finally got it to work

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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