View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Nigel Nigel is offline
external usenet poster
 
Posts: 923
Default Macro, Excel: insert cell between colored cells ??

Does whole of column A as required, change the Rows.Count to the last row if
less than whole column to be changed

Sub Inserter()
Dim xr As Long
With Sheets(1)
For xr = 2 To Rows.Count '<< change this to extent of rows
If .Cells(xr, 1).Interior.ColorIndex = 3 And .Cells(xr - 1,
1).Interior.ColorIndex = 5 Then
.Rows(xr).EntireRow.Insert shift:=xlDown
.Cells(xr, 1).Interior.ColorIndex = xlNone
End If
Next xr
End With
End Sub

--
Cheers
Nigel



"JVLennox" wrote in
message ...

Hi everybody!

I am trying to automatically insert an empty cell between colored
cells!

-- Each time I have a blue colored cell followed by a red colored cell
in column A, I want an empty cell to be inserted between these cells.

I tried to work something out, but all I can offer is this, which
determines the color. How do I get Excel to insert the cells throughout
the whole column A???

THANKS FOR ANY HELP!!!!

JVLennox




Range("????").Select
With Selection.Interior
ColorIndex = 5
Pattern = xlSolid
PatternColorIndex = xlAutomatic
End With
Range("????").Select
With Selection.Interior
ColorIndex = 3
Pattern = xlSolid
PatternColorIndex = xlAutomatic
End With


--
JVLennox
------------------------------------------------------------------------
JVLennox's Profile:

http://www.excelforum.com/member.php...o&userid=32505
View this thread: http://www.excelforum.com/showthread...hreadid=523180