VBA Express
[SOLVED] Insert blank row based on values in specified column [Archive] - VBA Express Forum

PDA

View Full Version : [SOLVED] Insert blank row based on values in specified column



pkearnes
09-18-2013, 09:09 AM
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.

patel
09-19-2013, 05:22 AM
attach please a small sample file with data and desired result

mancubus
09-19-2013, 07:40 AM
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

pkearnes
09-19-2013, 08:26 AM
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.

patel
09-19-2013, 09:01 AM
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

mancubus
09-19-2013, 11:03 AM
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.

pkearnes
09-19-2013, 11:17 AM
Works beautifully! Thank you so very much.

mancubus
09-20-2013, 12:43 AM
you are welcome.would you mind marking the thread as solved from "thread tools"?

pkearnes
09-20-2013, 03:41 AM
Absolutely! Thanks again.