C
carlos_ray86
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
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