How to replace the values within the conditional formatting range?

sneakikaz

New Member
Joined
Jun 8, 2022
Messages
14
Office Version
  1. 365
Platform
  1. Windows
My data has many number wherein some values are between 0 and -1. I labeled all of them with conditional formatting. However, it took quite a long time to replace all of them by 0. Is there any solution that help me to finish this more efficiently? Thank you very much.
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
This code go through cells with condition formatting, if their value >=0 and <=1, then delete.

VBA Code:
Option Explicit
Sub delete()
Dim cell As Range
For Each cell In ActiveSheet.UsedRange.SpecialCells(xlCellTypeAllFormatConditions)
    If cell.Value >= 0 And cell.Value <= 1 Then cell.Value = 0
Next
End Sub
 
Upvote 0
Solution
This code go through cells with condition formatting, if their value >=0 and <=1, then delete.

VBA Code:
Option Explicit
Sub delete()
Dim cell As Range
For Each cell In ActiveSheet.UsedRange.SpecialCells(xlCellTypeAllFormatConditions)
    If cell.Value >= 0 And cell.Value <= 1 Then cell.Value = 0
Next
End Sub
I am sorry but after I copy your code into the module, then run the macros, it does not work. Can you show me a more detailed tutorial? I am truly sorry because I have never used VBA before.
 
Upvote 0
This code go through cells with condition formatting, if their value >=0 and <=1, then delete.

VBA Code:
Option Explicit
Sub delete()
Dim cell As Range
For Each cell In ActiveSheet.UsedRange.SpecialCells(xlCellTypeAllFormatConditions)
    If cell.Value >= 0 And cell.Value <= 1 Then cell.Value = 0
Next
End Sub
Oh it works perfectly, thank you a lot.
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,162
Members
453,021
Latest member
Justyna P

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