VBA If statement

Pinaceous

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

If I have a cell that has both an interior yellow color with the text "TEST" as can be seen in the picture below:


Capture.PNG




How would do I create a vba if statement to say if both E has an interior color yellow and has the text "TEST" and the user wants to override/enter in a new value; it will return that new value and the interior color then goes away?

For example, If the user wants to override/enter in the value "Start" as seen in the picture the vba code will remove the interior color condition and text and provide whatever the user now entered.

Please let me know.

Thank you!
pinaceous

PS. I'm interested in vba format in lieu of conditional formatting.
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Try this in the corresponding Worksheet Module. Please note that changing the text back to "TEST" will not change the interior color back to yellow.
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("E:E")) Is Nothing Then
        If Target <> "TEST" And Target.Interior.Color = RGB(255, 255, 0) Then
            Target.Interior.Color = xlNone
        End If
    End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,788
Messages
6,121,588
Members
449,039
Latest member
Arbind kumar

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