Bob Kaplan
Seattle, WA, USA
Member
Members
Forum Posts: 17
Member Since:
July 29, 2013
July 29, 2013
Offline
This code does not work. I need to identify those cells that are NOT red in the a column and then delete the whole row. Then, I need to remove the red color.
'Delete cells with no red color
email = Application.match("email", Range("1:1"), 0)
finalrow = Cells(Rows.Count, 1).End(xlUp).Row
For counter3 = finalrow To 1 Step -1
If Cells(counter3, email).Interior.ColorIndex <> RGB(255, 0, 0) Then
Rows(counter3).Delete
End If
Next counter3
email = Application.match("email", Range("1:1"), 0)
finalrow = Cells(Rows.Count, 1).End(xlUp).Row
For counter3 = finalrow To 1 Step -1
If Cells(counter3, email).Interior.ColorIndex <> RGB(255, 0, 0) Then
Rows(counter3).Delete
End If
Next counter3
Philip Treacy
Admin
Forum Posts: 1619
Member Since:
October 5, 2010
October 5, 2010
Offline
Hi Bob,
Debug.Print prints information to the Immediate Window in the VBA Editor/Debugger. So Debug.Print Range("A1").DisplayFormat.Interior.Color prints the value of the DisplayFormat Interior Color of A1.
You can read about debugging and Debug.Print here
Regards
Phil
Purfleet
England
Member
Members
Trusted Members
Trusted Members
Forum Posts: 415
Member Since:
December 20, 2019
December 20, 2019
Offline
Just had a quick check and i think it is a combination of missing the displayformat & using colorindex rather than color
This deletes the red cells
Cells(counter3, email).DisplayFormat.Interior.Color = RGB(255, 0, 0)
but you had
Cells(counter3, email).Interior.ColorIndex = RGB(255, 0, 0)
Answers Post
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online:
Guest(s) 8
Currently Browsing this Page:
1 Guest(s)
1 Guest(s)
Top Posters:
Catalin Bombea: 1944
SunnyKow: 1432
Anders Sehlstedt: 956
Purfleet: 415
Hans Hallebeek: 377
Frans Visser: 351
David_Ng: 318
lea cohen: 248
Jessica Stewart: 219
A.Maurizio: 216
Newest Members:
Chris Holt
Michael Kirby
Malcolm Lambeth
Waqas Arshad
Techia Braveboy
Charles Buchanan
Tiago Braga
Rehan Baig
Fred HORVATH
Silke Schmidt
Forum Stats:
Groups: 3
Forums: 25
Topics: 7157
Posts: 31386
Member Stats:
Guest Posters: 50
Members: 34659
Moderators: 2
Admins: 3
Administrators: Mynda Treacy, Philip Treacy, Jessica
Moderators: Velouria, Riny van Eekelen
© Simple:Press —