+ Reply to Thread
Results 1 to 6 of 6

Copy and Paste Row If Condition is Met

  1. #1
    Registered User
    Join Date
    08-19-2012
    Location
    Denver
    MS-Off Ver
    Excel 2007
    Posts
    85

    Copy and Paste Row If Condition is Met

    Hello,

    Please help me with a macro that copies and pastes a row to another worksheet if a condition is met. Please see the attachment.

    This is what I need the macro to do:

    If Worksheet.FillOutThisForm.Range("E:E") contains the word "Sender", find the row in Worksheet.SendSide that contains the corresponding unique identifier in column L of Worksheet.FillOutThisForm. Then, copy the entire row from Worksheet.SendSide and paste in the next available row in Worksheet.Subjects.

    If Worksheet.FillOutThisForm.Range("E:E") contains the word "Payee", find the row in Worksheet.Payside1 that contains the corresponding unique identifier in column L of Worksheet.FillOutThisForm. Then, copy and paste the entire row from Worksheet.SendSide and paste in the next available row in Worksheet.Subjects.

    If Worksheet.FillOutThisForm.Range("E:E") contains the word "Both", then ignore that unique identifer and move on.

    The range of data in WorkSheet.FillOutThisForm.Range("E:E") will vary.

    Thank you for your help!

    Mattman123
    Attached Files Attached Files

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

    Re: Copy and Paste Row If Condition is Met

    Should the bold word not be "PaySide" instead of "SendSide" ?
    If Worksheet.FillOutThisForm.Range("E:E") contains the word "Payee", find the row in Worksheet.Payside1 that contains the corresponding unique identifier in column L of Worksheet.FillOutThisForm. Then, copy and paste the entire row from Worksheet.SendSide and paste in the next available row in Worksheet.Subjects.
    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]

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

    Re: Copy and Paste Row If Condition is Met

    Assuming its a typo at your end, use this code where Sender uses Sendside and Payee uses Payside sheets -
    Please Login or Register  to view this content.
    Copy the Excel VBA code
    Select the workbook in which you want to store the Excel VBA code
    Hold the Alt key, and press the F11 key, to open the Visual Basic Editor
    Choose Insert | Module
    Where the cursor is flashing, choose Edit | Paste

    To run the Excel VBA code:
    Choose View | Macros
    Select a macro in the list, and click the Run button

  4. #4
    Registered User
    Join Date
    08-19-2012
    Location
    Denver
    MS-Off Ver
    Excel 2007
    Posts
    85

    Re: Copy and Paste Row If Condition is Met

    Thank you so much for your reply, arlu1201, and I apologize for bumping the thread. Yes- you were correct about the typo.

    Upon implementing your code, I found two errors. First, for the first unique identifier "1234", it copied the row from both SendSide and PaySide, when it should just copy and paste the row from SendSide. In addition, it recopied and repasted the row for unique identifier 1234 from SendSide later.(Please see attached). Do you know why it might be doing this?
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    08-19-2012
    Location
    Denver
    MS-Off Ver
    Excel 2007
    Posts
    85

    Re: Copy and Paste Row If Condition is Met

    Nevermind, I was able to adjust. Thank you for your help!

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

    Re: Copy and Paste Row If Condition is Met

    Oops i forgot to mention that you need to have headers in the SendSide and PaySide files for it to work properly.

    How did you adjust it?

+ 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 copy from one sheet and paste in another if a condition is met.
    By dlholland1 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-29-2013, 09:41 AM
  2. Automate copy and paste based on condition
    By rlsublime in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 06-13-2012, 01:48 PM
  3. VBA Search for condition, copy and paste array
    By JohnKiernan in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-17-2012, 10:25 AM
  4. Copy paste based on a condition
    By jay36429 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-07-2011, 01:36 PM
  5. copy and paste from a cell until a condition is met
    By stevenjflores in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-02-2010, 01:26 PM

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