+ Reply to Thread
Results 1 to 4 of 4

VBA- Copy and paste rows if condition is met

  1. #1
    Registered User
    Join Date
    03-09-2018
    Location
    Langfang, China
    MS-Off Ver
    Office 2010
    Posts
    16

    Talking VBA- Copy and paste rows if condition is met

    Good afternoon, excel experts!

    I would like to have a macro that can search column D (deductibles) for all the non-zero values. Then insert an empty row immediately below, copy the deductible amount from column D into column C and turn it into a negative number. Copy down the company number, work order number and formulas in column F as well. Delete the entire column D.


    Example:

    Before:


    Column A Column B Column C Column D Column F
    Row 1 Company# Work Order# Amount Deductible
    Row 2 1 23632 $3250 $250 =TRIM(A2&"."&B2&"."&C2)
    Row 3 1 23638 $4250 $0 =TRIM(A3&"."&B3&"."&C3)
    Row 4 2 23642 $5250 $0 =TRIM(A4&"."&B4&"."&C4)
    Row 5 2 23657 $6250 $0 =TRIM(A5&"."&B5&"."&C5)

    After:

    Column A Column B Column C Column D
    Row 1 Company# Work Order# Amount
    Row 2 1 23632 $3250 =TRIM(A2&"."&B2&"."&C2)
    Row 3 1 23632 -$250 =TRIM(A3&"."&B3&"."&C3)
    Row 4 1 23638 $4250 =TRIM(A4&"."&B4&"."&C4)
    Row 5 2 23642 $5250 =TRIM(A5&"."&B5&"."&C5)
    Row 6 2 23657 $6250 =TRIM(A6&"."&B6&"."&C6)

    I have read a lot of posts but only managed to insert blank rows. I'd appreciate any help!
    Last edited by ANGIE90; 05-03-2018 at 06:50 PM.

  2. #2
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: VBA- Copy and paste rows if condition is met

    See if you can use this.

    Please Login or Register  to view this content.
    Any code provided by me should be tested on a copy or a mock up of your original data before applying it to the original. Some events in VBA cannot be reversed with the undo facility in Excel. If your original post is satisfied, please mark the thread as "Solved". To upload a file, see the banner at top of this page.
    Just when I think I am smart, I learn something new!

  3. #3
    Registered User
    Join Date
    03-09-2018
    Location
    Langfang, China
    MS-Off Ver
    Office 2010
    Posts
    16

    Re: VBA- Copy and paste rows if condition is met

    OMG

    Thank you so much! It works like magic!!

  4. #4
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: VBA- Copy and paste rows if condition is met

    Quote Originally Posted by ANGIE90 View Post
    OMG

    Thank you so much! It works like magic!!
    You're welcome
    Regards, JLG

+ 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. Copy Paste Certain Rows on a condition Macro
    By patelchandresh13 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-04-2016, 07:19 AM
  2. Macro to Copy and Paste if condition is met
    By olevia in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-10-2015, 02:56 PM
  3. [SOLVED] Copy paste with filtering condition
    By Jhon Mustofa in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-20-2014, 06:15 AM
  4. [SOLVED] Copy and Paste Row If Condition is Met
    By mattman123 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-14-2013, 01:26 PM
  5. Excel Macro to insert two rows based on condition and copy and paste multiple cells
    By mannabhalo in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-13-2012, 12:56 PM
  6. Copy and Paste Rows For certain condition then loop
    By steve70070 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-14-2011, 06:05 PM
  7. Replies: 1
    Last Post: 09-07-2010, 06:23 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