Hello all,
I have the following code attached to a command button:
Private Sub CommandButton1_Click()
Dim Number_of_rows As Long
Number_of_rows = ActiveSheet.UsedRange.Rows.Count
Range("c3").Select
Do Until Selection.Row = Number_of_rows + 1
If Selection.Value <> Selection.Offset(-1, 0).Value Then
Selection.EntireRow.Insert
Number_of_rows = Number_of_rows + 1
Selection.Offset(2, 0).Select
Else
Range("c3").Offset(1, 0).Select
End If
Loop
End Sub
This code loops thru column c and inserts a row between each
group of cells with different criteria. However this column may have a blank cell and this code still inserts a blank row.
I would like to amend this code to loop thru blank cells and
just insert a blank row that contains data.
Any suggestions would be greatly appreciated.
Thanks
Jon
I have the following code attached to a command button:
Private Sub CommandButton1_Click()
Dim Number_of_rows As Long
Number_of_rows = ActiveSheet.UsedRange.Rows.Count
Range("c3").Select
Do Until Selection.Row = Number_of_rows + 1
If Selection.Value <> Selection.Offset(-1, 0).Value Then
Selection.EntireRow.Insert
Number_of_rows = Number_of_rows + 1
Selection.Offset(2, 0).Select
Else
Range("c3").Offset(1, 0).Select
End If
Loop
End Sub
This code loops thru column c and inserts a row between each
group of cells with different criteria. However this column may have a blank cell and this code still inserts a blank row.
I would like to amend this code to loop thru blank cells and
just insert a blank row that contains data.
Any suggestions would be greatly appreciated.
Thanks
Jon