+ Reply to Thread
Results 1 to 3 of 3

Add rows after a set of data.

Hybrid View

  1. #1
    Registered User
    Join Date
    10-18-2013
    Location
    Indore, India
    MS-Off Ver
    Microsoft Office 2010
    Posts
    3

    Add rows after a set of data.

    Hello,

    I have a large .xlsx file in which I have about a million rows. I have let us say "categories" in Column F.

    Here is what I wish to achieve: Design a macro or any other solution that would,
    a) Search for the range of duplicate categories.
    b) Once the list ends, insert a blank row after that.

    Here is an example: The data inputted is like this:-
    F
    Metal
    Metal
    Metal
    Metal
    Metal
    Wooden
    Wooden
    Wooden
    Wooden
    Wooden
    Wooden
    Steel
    Steel
    Natural
    Metal
    Metal

    I want it to be:
    Metal
    Metal
    Metal
    Metal
    Metal

    Wooden
    Wooden
    Wooden
    Wooden
    Wooden
    Wooden

    Steel
    Steel

    Natural

    Metal
    Metal

    Notes:
    1. There are other columns too with data related to column F.
    2. I would be glad if I could get detailed instructions as, I am not at all aware with VBA but know basics of VB6 (just the basics).
    3. The Office version used is : Office 2007

    Regards,
    Kshitij

  2. #2
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Add rows after a set of data.

    Try:

    Sub TryThis()
    Dim icell As Long, lastrow As Long
    
    Application.ScreenUpdating = False
    
    lastrow = Range("F" & Rows.Count).End(xlUp).Row
    
    For icell = lastrow To 2 Step -1
        If Range("F" & icell).Value <> Range("F" & icell - 1).Value Then
            Range("F" & icell).EntireRow.Insert Shift:=xlDown
        End If
    Next icell
        
    Application.ScreenUpdating = True
    
    End Sub

  3. #3
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Add rows after a set of data.

    Maybe:

    Sub kshtjj()
    Application.ScreenUpdating = False
    Range("F3").Select
    Do Until ActiveCell.Value = ""
        If ActiveCell.Value <> ActiveCell.Offset(1).Value Then
            ActiveCell.Offset(1).EntireRow.Insert
            ActiveCell.Offset(2).Select
        Else
            ActiveCell.Offset(1).Select
        End If
    Loop
    Application.ScreenUpdating = True
    End Sub

+ 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. Replies: 1
    Last Post: 08-24-2013, 07:01 AM
  2. [SOLVED] Delete blank rows between data rows, shift rows up, then repeat
    By excelactuary in forum Excel General
    Replies: 2
    Last Post: 03-11-2013, 11:53 AM
  3. Replies: 6
    Last Post: 08-18-2012, 05:00 AM
  4. Replies: 1
    Last Post: 01-20-2012, 07:17 AM
  5. data rows to data columns and rows in sequence
    By Butehawk in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-24-2010, 08:11 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