Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 425
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 425
Default insert blank row


invalid post....

Wouldn't take "Rows(i:i).Select"

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 425
Default insert blank row

thanx but didnt quite work.

Was my starting code not good?


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 425
Default insert blank row

i give up.

trying another route.

thanx!
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I insert a true blank inst. of a non-blank zero string MF Excel Worksheet Functions 2 October 30th 09 01:58 PM
Insert Sum in blank Row Bernie Deitrick Excel Programming 0 April 3rd 08 07:14 PM
Start Cell B1 then find first blank cell, insert subtotal, next non blank, then next blank, sutotal cells in between......... [email protected][_2_] Excel Programming 2 June 7th 07 09:27 PM
Macro to insert copy and insert formulas only to next blank row bob Excel Programming 0 June 30th 06 12:02 PM
Macro code to test for blank row and insert blank row if false Mattie Excel Programming 2 March 29th 06 01:19 AM


All times are GMT +1. The time now is 12:19 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"