Results 1 to 7 of 7

Change in code to get it to insert two blank rows instead of one and paste text

Threaded View

  1. #1
    Registered User
    Join Date
    03-06-2014
    Location
    Denmark
    MS-Off Ver
    Excel 2010
    Posts
    83

    Change in code to get it to insert two blank rows instead of one and paste text

    Hello

    I have this code for searching a column when a number changes and insert rows above and below when there is a change.

    Sub InsertRows()
      Dim lastRow As Long
      Dim rowPtr As Long
      
      lastRow = Range("C" & Rows.Count).End(xlUp).Row
      For rowPtr = lastRow To 2 Step -2
        If Not IsEmpty(Range("C" & rowPtr)) Then
          If Range("C" & rowPtr) <> Range("C" & rowPtr - 1) Then
            Range("C" & rowPtr).EntireRow.Insert
          End If
        End If
      Next
    End Sub
    So fx. Column C:
    1
    1
    1
    2
    2

    Have to be:

    new row = "Text"
    1
    1
    1
    new row "Text 2"
    new row "text"
    2
    2
    new row "text 2"
    new row "Text"

    So when a new value begins: "Text"
    When it ends, "text 2"
    When the new value begins, same "text"
    when it ends, same "text 2

    Appreciate any help.
    Kind regards
    Last edited by arlu1201; 05-23-2014 at 12:10 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Changing code from deleting rows to cut/paste rows into another sheet and delete blank row
    By kmarshall6576 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-18-2013, 01:54 AM
  2. Replies: 1
    Last Post: 02-09-2012, 09:19 PM
  3. Insert Blank rows after every date change
    By josigrozi in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-15-2011, 07:23 AM
  4. Insert 2 blank rows and sum columns based on cell value change
    By parreola in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-27-2009, 11:14 PM
  5. Find blank rows and insert text
    By bpreas in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-09-2007, 10:43 AM

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