If I have 10 rows where this name appears it adds a blank above the first 5, and leaves the remaining unchanged.
if i have 40 rows, it adds a blank row above the first 20.
Use Code-Tags for showing your code: [code] Your Code here [/code]
Please mark your question Solved if there has been offered a solution that works fine for you
Sub InsertBlankRows() Dim Cls As Range, Rng As Range, J As Long
Set Rng = Range([a2], [a2].End(xlDown)) Columns("A:A").Insert Shift:=xlToRight Union([A1], [A1].Offset(Rng.Rows.Count)).Value = "xxx.xxx" For Each Cls In Rng J = J + 1 Cls.Offset(, -1).Value = "A" & Right("000" & CStr(J), 4) If Left(Cls.Value, 5) = "EV01_" Then Cells(Rows.Count, "A").End(xlUp).Offset(1).Value = "A" & Right("000" & CStr(J), 4) & "1" End If Next Cls
[A1].CurrentRegion.Sort Key1:=Range("A2"), Order1:=xlAscending, Header:=xlGuess, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom Columns("A:A").Delete Shift:=xlToLeft End Sub
Last edited by FDibbins; 06-09-2014 at 10:14 PM.
Reason: unnecessary web link removed
Bookmarks