Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Value change change cell color 1

Status
Not open for further replies.

sofiavba

Programmer
Apr 4, 2006
19
US
Hi everyone,

First off I just wanted to say that this is GREAT, I have gotten so much good advice that I cant thank everyone enough.

Ok here is the problem, I have a cell on my spreadsheet, which if empty when the sheet is opened. I want the cell to change its color when a user goes in and enters a number. The cell also has a formula in it, if the formula is used the cell's color should not changed, only when a user selects the cell and changes the value should the color change.I cant use the conditional formatting because it just will not do the trick.

Any ideas?
 


So when the user change the value, the formula is destroyed.

Is that your design?

What happens the next time when there's no formula?



Skip,

[glasses] [red]Be Advised![/red] A chicken, who would drag a wagon across the road for 2 cents, is…
POULTRY in motion to PULLET for a PALTRY amount! [tongue]
 
If the users enters a value we do nothing actually, the design at this point is to allow the user full access to all fields and formulas can be distroyed if needed.

But we do want to know if the formula was replaced by a user entering data.
 


The use the Worksheet_Change event (right click the sheet tab and select View Code).

If the Target address equals the cell address, then your case is true. Paste this code and modify as needed for your cell reference and colorindex.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address = [a1].Address Then target.interior.colorindex = 5
End Sub
use you macro recorder to find a colorindex that suits you.

Skip,

[glasses] [red]Be Advised![/red] A chicken, who would drag a wagon across the road for 2 cents, is…
POULTRY in motion to PULLET for a PALTRY amount! [tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top