+ Reply to Thread
Results 1 to 2 of 2

Add a row

Hybrid View

skooter2k5 Add a row 08-18-2010, 03:19 PM
sweep Re: Add a row 08-18-2010, 03:36 PM
  1. #1
    Registered User
    Join Date
    04-13-2010
    Location
    Huntsville, Alabama
    MS-Off Ver
    Excel 2003
    Posts
    5

    Add a row

    Hi,
    I have searched the forum but nothing I have found does exactly what I need it to.

    I need a macro that will add a row between two cells if they are not identical.
    Here's the best way I can explain it.

    If A1 is not equal to A2, then insert a row between them. If A1 is equal to A2 then do nothing.
    If A2 is not equal to A3, then insert a row between them. If A2 is equal to A3 then do nothing.
    If A3 is not equal to A4, then insert a row between them. If A3 is equal to A4 then do nothing.

    This formula needs to keep going until it reaches A500.

    Please help.

  2. #2
    Forum Expert sweep's Avatar
    Join Date
    04-03-2007
    Location
    Great Sankey, Warrington, UK
    MS-Off Ver
    2003 / 2007 / 2010 / 2016 / 365
    Posts
    3,454

    Re: Add a row

    How's this for you?

    Sub versive()
    Dim iRow As Integer
    
    For iRow = 500 To 2 Step -1
    If Not Range("A" & iRow).Value = Range("A" & iRow - 1).Value Then Range("A" & iRow).EntireRow.Insert
    Next
    
    End Sub
    Rule 1: Never merge cells
    Rule 2: See rule 1

    "Tomorrow I'm going to be famous. All I need is a tennis racket and a hat".

+ 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