+ Reply to Thread
Results 1 to 4 of 4

VBA to Insert Rows if Specific Condition is met.

  1. #1
    Registered User
    Join Date
    03-28-2016
    Location
    Indiana
    MS-Off Ver
    2013
    Posts
    5

    VBA to Insert Rows if Specific Condition is met.

    Hi,

    I'm trying to write code where if a specific Value, in this case "E0381EAF" exists, input a certain number of rows below this row. I'm pretty close, but I can't get the correct number of rows added.


    Sub EntityPercentage()

    UsedRows = Worksheets("2. BA&R Customer Product Tab").Range("b1").Value
    numberofrows = Worksheets("2. BA&R Customer Product Tab").Range("a1").Value

    For Each c In Range("B10:B" & UsedRows)
    If c.Value Like "E0381EAF" Then
    c.Offset(numberofrows).EntireRow.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
    End If
    Next c


    End Sub

    Thanks,
    Dan

  2. #2
    Forum Contributor
    Join Date
    01-04-2013
    Location
    Tampa, Florida
    MS-Off Ver
    Excel 2013
    Posts
    142

    Re: VBA to Insert Rows if Specific Condition is met.

    Try this:

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    03-28-2016
    Location
    Indiana
    MS-Off Ver
    2013
    Posts
    5

    Re: VBA to Insert Rows if Specific Condition is met.

    Thanks that worked. I appreciate the quick response...

    Do you know how you would copy the row above and paste that into the blank rows?

  4. #4
    Forum Contributor
    Join Date
    01-04-2013
    Location
    Tampa, Florida
    MS-Off Ver
    Excel 2013
    Posts
    142

    Re: VBA to Insert Rows if Specific Condition is met.

    Try this:

    Please Login or Register  to view this content.
    Had to take a different approach and start from the bottom of the data and work our way up to the top so that the procedure didn't find and try to act on the new rows that were inserted.

+ 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. Insert 0 into specific column and specific rows
    By csincava in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-17-2015, 04:49 PM
  2. [SOLVED] Insert Rows on Criteria and Copy content to Specific Cells in New Rows(Tables)
    By TheScott in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-01-2015, 03:38 PM
  3. vba code to insert blank row after specific condition is met
    By archies.gall in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-24-2014, 05:07 AM
  4. Need to insert Rows Based on a Condition
    By skandkamat in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-17-2013, 12:06 AM
  5. [SOLVED] Macro to Insert blank rows based on condition
    By Nikkishr in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-07-2012, 03:32 AM
  6. Excel macro that would insert rows with condition
    By Shimba2011 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-16-2011, 09:28 AM
  7. Macro that will insert rows with condition
    By Shimba2011 in forum Excel General
    Replies: 0
    Last Post: 11-07-2011, 03:14 PM

Tags for this Thread

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