Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
insert blank row
Want to insert blank row right before the first instance where a row
color is gray (color index 41). Tried to work out the folliowing but no success. Sub InsertRows() Dim i As Long i = 2 Do Until Trim(Cells(i, 1)) = "" If cell.Interior.ColorIndex = 41 Then Cells(i, 1).EntireRow.Insert i = i + 2 Else i = i + 1 End If End Sub |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
insert blank row
On Jun 27, 11:08*am, "J.W. Aldridge"
wrote: Want to insert blank row right before the first instance where a row color is gray (color index 41). Tried to work out the folliowing but no success. Sub InsertRows() Dim i As Long i = 2 Do Until Trim(Cells(i, 1)) = "" If cell.Interior.ColorIndex = 41 Then Cells(i, 1).EntireRow.Insert i = i + 2 Else i = i + 1 End If End Sub try replacing cells(i,1).entirerow with Rows(i:i).Select Selection.Insert Shift:=xlDown Regards |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
insert blank row
invalid post.... Wouldn't take "Rows(i:i).Select" |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
insert blank row
Try this:
Sub InsertRows() Dim i As Long i = 2 Do Until Trim(Cells(i, 1)) = "" If Cells(i, 1).Interior.ColorIndex = 41 Then Cells(i, 1).EntireRow.Insert i = i + 2 Else i = i + 1 End If Loop End Sub Regards, Per On 27 Jun., 12:39, "J.W. Aldridge" wrote: invalid post.... Wouldn't take "Rows(i:i).Select" |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
insert blank row
thanx but didnt quite work.
Was my starting code not good? |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
insert blank row
You need a Loop statement to finish the Do / Loop loop, and in the
line: If cell.Interior.ColorIndex ..... you have not Set any reference to the cell variable. Best regards, Per On 27 Jun., 13:23, "J.W. Aldridge" wrote: thanx but didnt quite work. Was my starting code not good? |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
insert blank row
i give up.
trying another route. thanx! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How can I insert a true blank inst. of a non-blank zero string | Excel Worksheet Functions | |||
Insert Sum in blank Row | Excel Programming | |||
Start Cell B1 then find first blank cell, insert subtotal, next non blank, then next blank, sutotal cells in between......... | Excel Programming | |||
Macro to insert copy and insert formulas only to next blank row | Excel Programming | |||
Macro code to test for blank row and insert blank row if false | Excel Programming |