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: 1609
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: Sara Sartori, Sarah Yelland
Guest(s) 9
Currently Browsing this Page:
1 Guest(s)
1 Guest(s)
Top Posters:
Catalin Bombea: 1939
SunnyKow: 1432
Anders Sehlstedt: 917
Purfleet: 415
Frans Visser: 349
Hans Hallebeek: 331
David_Ng: 306
lea cohen: 248
Jessica Stewart: 219
A.Maurizio: 216
Newest Members:
Sarah Yelland
Ahsan AYUB
Daniel Neilson
Joy Nicholes
Earl Hanlon
Paulo Pinto
Tavonga Machigere
Marc Poulopoulos
Viki Hennon
David Tucker
Forum Stats:
Groups: 3
Forums: 25
Topics: 7058
Posts: 30931
Member Stats:
Guest Posters: 49
Members: 34427
Moderators: 2
Admins: 3
Administrators: Mynda Treacy, Philip Treacy, Jessica
Moderators: Velouria, Riny van Eekelen
© Simple:Press —