LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 67
Default Why does this happen same code different results

The following code takes a range that consists of cells that are all
from the B column. When the data in the A column is red it makes the
row next to it red(the B column) along with the three rows under.
Example Column A row 20 is red so column B row 20 through 24 would
turn red. It works great everytime. However, I want those colums that
are red to be deleted so I did this little state "If Cells
(i,w).Font.ColorIndex=3 Then Cells(i,w).delete" I have i= 1 to 100 and
w=1 to 100. I thought that that would look in my range and find all of
the data in red and delete it but it doesn't for some reason just
some of the read is still there. So I thought well what if instead of
initially turning those four rows red (the statements below) I just
say .delete instead of rng3.Font.ColorIndex = 3 and the same rows that
were not delete from the prior attempt again are there. So basically I
right the same code and just switch rng3.Font.ColorIndex = 3
to .Delete but I get different outcome. Why is that? Thanks for the
help.



Dim rng1 As Range
Dim rng2 As Range
Dim rng3 As Range
Dim e As Integer


For e = 1 To 300
Set rng1 = Range(Cells(e, 2), Cells(e + 1, 2))
Set rng2 = Range(Cells(e + 2, 2), Cells(e + 3, 2))
Set rng3 = Union(rng1, rng2)
If Cells(e, 1).Font.ColorIndex = 3 Then rng3.Font.ColorIndex =
3<----'Try to switch to.Delete

Next
End Sub

 
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
Wow... Anyone ever seen this happen? Dan R. Excel Discussion (Misc queries) 1 March 16th 07 07:34 PM
Why is that happen ? 0xC00D11CD Excel Worksheet Functions 1 May 22nd 06 01:14 PM
Same code - different results scott_hanebutt Excel Programming 0 January 3rd 06 07:59 PM
why would this happen? JENNYC Excel Discussion (Misc queries) 3 December 12th 05 05:56 PM
Sorry for the attachment. new and just trying to help. It will not happen again. Gary[_18_] Excel Programming 1 July 3rd 04 01:46 AM


All times are GMT +1. The time now is 02:19 PM.

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

About Us

"It's about Microsoft Excel"