+ Reply to Thread
Results 1 to 3 of 3

Insert multiple rows to when data is different in columns

  1. #1
    Registered User
    Join Date
    11-06-2014
    Location
    Detroit
    MS-Off Ver
    2007
    Posts
    2

    Insert multiple rows to when data is different in columns

    I have 11 columns with headers. I need to insert three rows when data in columns B and C are different. Example:

    Column B has a date, Column C has country code

    DATE COUNTRY
    9/16/2014 MAYS
    9/16/2014 MAYS
    9/16/2014 MAYS
    9/16/2014 INDI
    9/16/2014 INDI


    I need the macro to insert 3 rows between the date and country

    DATE COUNTRY
    9/16/2014 MAYS
    9/16/2014 MAYS
    9/16/2014 MAYS



    9/16/2014 INDI
    9/16/2014 INDI

    I will have a spreadsheet of multiple dates and countries in Column B and C, so need to insert rows then upon selecting macro

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,168

    Re: Insert multiple rows to when data is different in columns

    Hi jak and welcome to the forum,

    It is normally a bad idea to insert blank rows or columns in a table. What are you trying to get for your answer. I'd expect there is a better way to get an answer without needing to insert blank rows. If you can attach a sample workbook and show what you have and what kind of answer you want, it would be much more help for us and you.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Registered User
    Join Date
    11-06-2014
    Location
    Detroit
    MS-Off Ver
    2007
    Posts
    2

    Re: Insert multiple rows to when data is different in columns

    Hi Marvin,


    I am using this macro

    Sub InsertRowAtChangeInValue()
    Dim lRow As Long
    For lRow = Cells(Cells.Rows.Count, "C").End(xlUp).Row To 2 Step -1
    If Cells(lRow, "C") <> Cells(lRow - 1, "C") Then Rows(lRow).EntireRow.Insert
    Next lRow
    End Sub

    However, I have to run it twice and then delete rows 2-4 manually, otherwise it works perfect.

    Basically, I need to insert the three rows, then add 4 columns to the end with specific headers. After that, I then subtotal amounts for each group in columns K and O.

+ 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. count columns with data then insert that number of rows
    By johnson1421 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-12-2014, 06:54 PM
  2. Replies: 9
    Last Post: 12-15-2013, 10:05 PM
  3. [SOLVED] Insert Multiple Rows Based Off Number in Cell and Copy Data From Above New Rows
    By tstell1 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-02-2012, 04:15 PM
  4. [SOLVED] How to take data from columns in some rows and insert in new row?
    By janschepens in forum Excel General
    Replies: 8
    Last Post: 04-25-2012, 10:07 AM
  5. Insert Multiple Columns Between Data
    By masterp in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-20-2006, 08:41 AM

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