Results 1 to 4 of 4

Inserting blank rows when data in column changes

Threaded View

  1. #4
    Registered User
    Join Date
    03-05-2010
    Location
    Essex, England
    MS-Off Ver
    Excel 2003
    Posts
    62

    Re: Inserting blank rows when data in column changes

    Hi everyone

    I've spent most of today trying to upload my file so have now given up! I will keep going as I was before!

    Below is the code that inserts 6 rows when the data in column B changes. I now need to insert a further two when the data in column C changes

    Sub insertblankrow()
    Dim fr As Long
    Dim i As Long
    fr = Cells(Rows.Count, 3).End(xlUp).Row
    For i = fr To 2 Step -1
    If Cells(i, 2).Value <> Cells(i - 1, 2).Value Then
    Rows(i).Insert
    Rows(i).Insert
    Rows(i).Insert
    Rows(i).Insert
    Rows(i).Insert
    Rows(i).Insert
    End If
    Next i
    End Sub
    This is the code (below) I was given but I think it doesn't work because of the pre existing blank rows created during the last macro. I get an error to do with If block.

    If Cells(i, 2).Value <> Cells(i - 1, 2).Value Then Rows(i & ":" & i + 1).Insert
    OMG have managed to upload attachment - have deleted most of it so suspect it was size causing probs. I hope this helps to understand my query.

    I've included the steps I'm using to approach this (not sure if they're clear with most of the w/book missing) and would be grateful if someone could check them over, just in case I'm living in cloud cuckoo land!

    Thanks again in anticipation!
    Attached Files Attached Files

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