VBA If Range ...

Pinaceous

Well-known Member
Joined
Jun 11, 2014
Messages
1,113
Office Version
  1. 365
Platform
  1. Windows
Hi All,

I'm looking for a vba code upon to run upon Range A1:D5 where if there is an interior color red cell and it contains a value that the sub will remove its interior color for that range.

For example, if I have the following situation and then I run the sub,

Capture1 .JPG



It will return:

Capture2 .JPG



Can someone please help me?

Thank you!
pinaceous
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Hi Pin
How is the Red color placed there in the first place ?
Is it CF or manually input ?
 
Upvote 0
Give this macro a try...
VBA Code:
Sub IfRedAndValueRemoveRed()
  Dim Cell As Range
  For Each Cell In Cells.SpecialCells(xlConstants)
    If Cell.Interior.Color = vbRed And Cell.Value <> "" Then
      Cell.Interior.Color = xlNone
    End If
  Next
End Sub
 
Upvote 0
Give this macro a try...
VBA Code:
Sub IfRedAndValueRemoveRed()
  Dim Cell As Range
  For Each Cell In Cells.SpecialCells(xlConstants)
    If Cell.Interior.Color = vbRed And Cell.Value <> "" Then
      Cell.Interior.Color = xlNone
    End If
  Next
End Sub
Rick Rothstein!

Thank you very much for responding to my post!

Curious, do you know how I can specify a specific range?

For example, Range A1:D5.

Please let know,

Thank you,
pinaceous
 
Upvote 0
Curious, do you know how I can specify a specific range?

For example, Range A1:D5.
Try this way...
Rich (BB code):
Sub IfRedAndValueRemoveRed()
  Dim Cell As Range
  For Each Cell In Range("A1:D5")
    If Cell.Interior.Color = vbRed And Cell.Value <> "" Then
      Cell.Interior.Color = xlNone
    End If
  Next
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,084
Messages
6,123,021
Members
449,092
Latest member
ikke

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