+ Reply to Thread
Results 1 to 4 of 4

insert rows based on text values in cells

Hybrid View

  1. #1
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: insert rows based on text values in cells

    Hi Simarui,

    Try this:

    Sub ABC(): Dim r As Long, i As Long
    r = 2: Do Until Cells(r, 1) = "" And Cells(r + 1, 1) = ""
    ReComp:
    If Trim(Cells(r, 1)) = "" Then
    r = r + 1: GoTo ReComp: End If
    If Trim(Cells(r, 1)) = "a" Then
    NoComp:
        If Trim(Cells(r + 1, 1)) = "b" Then
    HalfComp:
            If Cells(r + 2, 1) = "c" Then
                r = r + 3: GoTo FullComp
            Else: Cells(r + 2, 1).EntireRow.Insert
                    r = r + 3: GoTo FullComp: End If
        Else: Cells(r + 1, 1).EntireRow.Insert     'the b row
        GoTo HalfComp: End If
    Else: Cells(r, 1).EntireRow.Insert: GoTo NoComp: End If
    
    FullComp: Loop
    End Sub
    Last edited by xladept; 02-20-2014 at 07:14 PM. Reason: Cautionary Change
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

+ 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. [SOLVED] Insert rows based on the current cell value and, then, copy some cells into the new rows
    By Excel-RZ in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 11-03-2013, 05:19 PM
  2. I need to insert rows using macros, based on rows values. Please Help!
    By reservoirimgaging in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-19-2013, 02:13 PM
  3. Insert rows based on values in column
    By scott p in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-11-2013, 01:58 PM
  4. [SOLVED] Insert number of rows with data to new sheets based on values in cells
    By keithtran12 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-28-2013, 11:57 AM
  5. Insert rows based on start/end values
    By JP Romano in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 01-09-2012, 10:41 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