
inserting a row to every second line.
From a strictly academic point of view, it would appear this could not be
done without a programming loop.
So, just for fun... Dana DeLouis.
Sub InsertRows()
'// Insert Alternating blank rows.
'// & Color every other Row
'// By: Dana DeLouis
Dim c As Long
Const LastRow As Long = 1000
Application.ScreenUpdating = False
ActiveSheet.UsedRange
c = Cells.SpecialCells(xlLastCell)(1, 2).Column
Cells(1, c) = "TRUE"
Cells(1, c).Resize(2, 1).AutoFill _
Destination:=Range(Cells(1, c), Cells(LastRow, c))
Columns(c).SpecialCells(xlBlanks).EntireRow.Insert
Cells(1, c).ClearContents
Columns(c).SpecialCells(xlConstants).EntireRow.Insert
With Columns(c).SpecialCells(xlConstants)
Union(Cells(1, c), Cells(3, c), .Offset(2, 0)).Value = True
End With
Columns(c).SpecialCells(xlBlanks).EntireRow.Interior.ColorIndex = 15
Columns(c).ClearContents
ActiveSheet.UsedRange
[A1].Select
Application.ScreenUpdating = True
End Sub
Quote:
> Hi I am trying to insert a new line and gray the (new inserted) line then
> move down and format the next line so that the spreadsheet looks like
every
> second line is greyed and blank.
> I want to apply this to the first 1000 lines and am trying to use the
count
> command with the following code.
> Sub ChkFirstWhile()
> counter = 1
> myNum = 1
> Do While myNum < 1000
> Rows ("counter:counter").Select
> Selection.Insert Shift:=xlDown
> Selection.Interior.ColorIndex = 15
> 'End With
> myNum = myNum - 1
> counter = counter + 1
> Loop
> 'MsgBox "The loop made " & counter & " repetitions."
> End Sub
> Only problem is that excel does not like my count command.
> Any suggestions?