Cell Color changes On Input even if new input matches default

J

JBark

Cell Color changes On Input even if new input matches default...

I have a Macro Button which sets a Range of Cells to this default:
(example)
Sub SetDefaultCells()
Range("B10").Value = "8:30 AM"
Range("B10").Interior.Color = vbYellow
End Sub

How can I place a code into this cell so that when the user changes the time
it changes the cell color? My problem is that the user may need to keep it at
8:30 AM, so can I change the cell color even if the user inputs the same data
if they key in the same data as the default? This is why I can not use
conditional formatting. I can't use onActive Cell either because when the
user hits Enter it will go to the next cell and if I use onClick the user may
not use the click function.

Any help is greatly appreciated. Thanks!
 
J

Jacob Skaria

Select the sheet tab which you want to work with. Right click the sheet tab
and click on 'View Code'. This will launch VBE. Paste the below code to the
right blank portion. Get back to to workbook and try out.

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Target, Range("B10")) Is Nothing Then _
Range("B10").Interior.ColorIndex = xlNone
End Sub

If this post helps click Yes
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top