+ Reply to Thread
Results 1 to 3 of 3

Creating blank rows between different values in a column

  1. #1
    Registered User
    Join Date
    03-17-2008
    Posts
    16

    Creating blank rows between different values in a column

    I am trying to create a simple macro that looks at a specific column, starts at row 1 and inserts a blank row whenever a new value appears below it.

    For example, if column B looked like this:

    SERPO <--Row 1
    SERPO
    SERPO
    TACOMA
    TACOMA
    TACOMA
    CINCINNATI
    CINCINNATI
    HOPKINS
    HOPKINS
    HOPKINS

    The macro would insert a row between serpo and tacoma, tacoma and cincinnati, etc. like this:

    SERPO
    SERPO
    SERPO

    TACOMA
    TACOMA
    TACOMA

    CINCINNATI
    CINCINNATI

    HOPKINS
    HOPKINS
    HOPKINS

    I'm really only familiar with using the macro recorder, so I didn't know of a way to do this. I have to do this daily and there are usually 30+ different values and 4000+ lines so I'm trying to create a time saver.
    Last edited by MadCrammer; 03-09-2010 at 10:22 AM.

  2. #2
    Valued Forum Contributor JeanRage's Avatar
    Join Date
    03-02-2009
    Location
    Nice, France
    MS-Off Ver
    Excel 2003
    Posts
    705

    Re: Creating blank rows between different values in a column

    Hi,

    You could test following for column B ...
    Sub insertblankrow()
    Dim fr As Long
    Dim i As Long
    fr = Cells(Rows.Count, 2).End(xlUp).Row
    For i = fr To 2 Step -1
    If Cells(i, 2).Value <> Cells(i - 1, 2).Value Then Rows(i).Insert
    Next i
    End Sub
    HTH

  3. #3
    Registered User
    Join Date
    03-17-2008
    Posts
    16

    Re: Creating blank rows between different values in a column

    That works great, thank for the help!

+ 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