VBA Cells and if

jamada

Active Member
Joined
Mar 23, 2006
Messages
323
Hi, the first IF works very well thanks to the contributors/helpers on this board.
Question though, id like to delete a row if certain cells contain a certain color (RGB120,20,50). However not working well for me, any suggestions please?


For i = LastRow To 2 Step -1
If Cells(i, 2).Value > 0 Then
Range(Cells(i, 8), Cells(i, 12)).Offset(3).FormulaR1C1 = "=CONCATENATE(R[-2]C,"" "",LEFT(R[-1]C,1),""."")"
Range(Cells(i + 1, 8), Cells(i + 1, 12)).Value = Range(Cells(i + 3, 8), Cells(i + 3, 12)).Value
Range(Cells(i, 8), Cells(i, 12)).Offset(2).EntireRow.Delete
Range(Cells(i, 8), Cells(i, 12)).Offset(2).EntireRow.Delete
Range(Cells(i, 1), Cells(i, 7)).Cut Range(Cells(i + 1, 1), Cells(i + 1, 7))

If Range(Cells(i - 1, 1), Cells(i - 1, 6)).Interior.Color = RGB(150, 20, 50) Then
Range(Cells(i - 1, 1),Cells(I - 1, 6 ).offset(-1).EntireRow.Delete
End If
End If
Next i
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
your if says that: If ALL cells in that range are rgb(..) then...
maybe you need if statement when any of cells in that range is rgb(...)?
 
Upvote 0
Thanks S_Wish, I've even narrowed in down to one cell that color, however doesn't seem to work... not sure why and still seekig a solution.
 
Upvote 0

Forum statistics

Threads
1,224,827
Messages
6,181,199
Members
453,022
Latest member
RobertV1609

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top