
Bob Kaplan
Seattle, WA, USA
Member
Members

Forum Posts: 17
Member Since:
July 29, 2013
July 29, 2013

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: 1550
Member Since:
October 5, 2010
October 5, 2010

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: 414
Member Since:
December 20, 2019
December 20, 2019

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: DOMINIQUE SAUVAGE, Hanan Khan, Jack Aston, Martin Delloca
Guest(s) 11
Currently Browsing this Page:
1 Guest(s)
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 880
Purfleet: 414
Frans Visser: 346
David_Ng: 306
lea cohen: 237
Jessica Stewart: 219
A.Maurizio: 213
Aye Mu: 201
Hans Hallebeek: 185
Newest Members:
Kwaje Alfred Mogga
thong nguyen
Appiagyei Kofi Frimpong
Hilary Burchfield
Richie Wright
Adel Kock
Barbara Murray
Doug Milne
Siobhan Stringer
Rob Rooth
Forum Stats:
Groups: 3
Forums: 24
Topics: 6546
Posts: 28654
Member Stats:
Guest Posters: 49
Members: 32831
Moderators: 2
Admins: 4
Administrators: Mynda Treacy, Philip Treacy, Catalin Bombea, FT
Moderators: Velouria, Riny van Eekelen
© Simple:Press —
