VBA to remove highlighted cells

Yamasaki450

Board Regular
Joined
Oct 22, 2021
Messages
71
Office Version
  1. 2021
Platform
  1. Windows
Hello again. :)

I would kindly ask for another VBA to remove red highlighted cells. Cells are highlighted with conditional formatting.

Thanks guys.
 

Attachments

  • 3.png
    3.png
    40.4 KB · Views: 24

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Hi Yamasaki,
What have you tried so far?
See if you can create a macro that:
Sets a range, Ideally either a selection, or a hard coded range.
Then for each cell in the range check to see if the interior color is red.
if it is clearcontents.
if not move on.
 
Upvote 0
Hi Yamasaki,
What have you tried so far?
See if you can create a macro that:
Sets a range, Ideally either a selection, or a hard coded range.
Then for each cell in the range check to see if the interior color is red.
if it is clearcontents.
if not move on.
Hey. Thanks but i have no clue how to write macro code heh :) Thats why im asking here if someone is willing to write it.
 
Upvote 0
Does this macro do what you want (it physically clears the cells that are shown in red)...
VBA Code:
Sub ClearRedCells()
  Dim Cell As Range
  Application.ScreenUpdating = False
  For Each Cell In Range("F3:L23")
    If Cell.DisplayFormat.Interior.Color = vbRed Then
      Cell.Clear
    End If
  Next
  Application.ScreenUpdating = True
End Sub
 
Last edited:
Upvote 0
If this is a follow-up question for the thread titled "vba-macro-to-delete-highlighted-cells," please provide the link to the thread so that everyone who reads this can understand the context. An important detail from the previous thread is that you are working with over 14 million cells.


Cells are highlighted with conditional formatting.
What is formula of the conditional formatting?
 
Upvote 0
If this is a follow-up question for the thread titled "vba-macro-to-delete-highlighted-cells," please provide the link to the thread so that everyone who reads this can understand the context. An important detail from the previous thread is that you are working with over 14 million cells.



What is formula of the conditional formatting?
I used this formulas to give cells color "=AND($C2=3,D2<=-4,D2>=-65)"

Post #2 in this thread.
 
Upvote 0
But in your example in post #1 there are no data in col C, why?
I didnt use formula in post #1. I did it manually with conditional formatting rule just to show what i want... I didnt know that formula is important... Here is example with formula.
 

Attachments

  • 4.png
    4.png
    50 KB · Views: 20
Upvote 0

Forum statistics

Threads
1,224,825
Messages
6,181,190
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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