Consulting

Results 1 to 9 of 9

Thread: Insert blank row based on values in specified column

  1. #1

    Insert blank row based on values in specified column

    I have a spreadsheet with 25 columns and 811 rows. The values in column "AA" are numeric and indicate a group ID of all possible duplicate records. I need to insert a blank row after each unique value in column "AA". Any suggestions?

    Thanks.

  2. #2
    VBAX Mentor
    Joined
    Jul 2012
    Posts
    398
    Location
    attach please a small sample file with data and desired result

  3. #3
    VBAX Guru mancubus's Avatar
    Joined
    Dec 2010
    Location
    "Where I lay my head is home" :D
    Posts
    2,644
    Sub Insert_Rows_after_groups()
        For i = Cells(Rows.Count, "AA").End(xlUp).Row To 2 Step -1
          If Cells(i - 1, "AA") <> Cells(i, "AA") Then Cells(i, 1).EntireRow.Insert
        Next i
    End Sub
    Last edited by mancubus; 09-19-2013 at 11:00 AM.
    PLS DO NOT PM; OPEN A THREAD INSTEAD!!!

    1) Posting Code
    [CODE]PasteYourCodeHere[/CODE]
    (or paste your code, select it, click # button)

    2) Uploading File(s)
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) (multiple files can be selected while holding Ctrl key) / Upload Files / Done
    Replace company specific / sensitive / confidential data. Include so many rows and sheets etc in the uploaded workbook to enable the helpers visualize the data and table structure. Helpers do not need the entire workbook.

    3) Testing the Codes
    always back up your files before testing the codes.

    4) Marking the Thread as Solved
    from Thread Tools (on the top right corner, above the first message)

  4. #4
    Sample file attached. Test Tab= data that needs the blank rows inserted. Test result Tab = data with blank rows following groups of unique values in column AA.
    Attached Files Attached Files

  5. #5
    VBAX Mentor
    Joined
    Jul 2012
    Posts
    398
    Location
    missing "<>" in mancubus code
    Sub Insert_Rows_after_groups()
    For i = Cells(Rows.Count, "AA").End(xlUp).Row To 2 Step -1
     If Cells(i - 1, "AA") <> Cells(i, "AA") Then Cells(i, 1).EntireRow.Insert
    Next i
    End Sub

  6. #6
    VBAX Guru mancubus's Avatar
    Joined
    Dec 2010
    Location
    "Where I lay my head is home" :D
    Posts
    2,644
    Quote Originally Posted by patel View Post
    missing "<>" in mancubus code
    it's a copy-paste problem in internet explorer in my office computer, i think.
    also line feeds are not pasted here.
    PLS DO NOT PM; OPEN A THREAD INSTEAD!!!

    1) Posting Code
    [CODE]PasteYourCodeHere[/CODE]
    (or paste your code, select it, click # button)

    2) Uploading File(s)
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) (multiple files can be selected while holding Ctrl key) / Upload Files / Done
    Replace company specific / sensitive / confidential data. Include so many rows and sheets etc in the uploaded workbook to enable the helpers visualize the data and table structure. Helpers do not need the entire workbook.

    3) Testing the Codes
    always back up your files before testing the codes.

    4) Marking the Thread as Solved
    from Thread Tools (on the top right corner, above the first message)

  7. #7
    Works beautifully! Thank you so very much.

  8. #8
    VBAX Guru mancubus's Avatar
    Joined
    Dec 2010
    Location
    "Where I lay my head is home" :D
    Posts
    2,644
    you are welcome.would you mind marking the thread as solved from "thread tools"?
    PLS DO NOT PM; OPEN A THREAD INSTEAD!!!

    1) Posting Code
    [CODE]PasteYourCodeHere[/CODE]
    (or paste your code, select it, click # button)

    2) Uploading File(s)
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) (multiple files can be selected while holding Ctrl key) / Upload Files / Done
    Replace company specific / sensitive / confidential data. Include so many rows and sheets etc in the uploaded workbook to enable the helpers visualize the data and table structure. Helpers do not need the entire workbook.

    3) Testing the Codes
    always back up your files before testing the codes.

    4) Marking the Thread as Solved
    from Thread Tools (on the top right corner, above the first message)

  9. #9
    Absolutely! Thanks again.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •