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 sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is it possible to run a macro dependent on the contents of a cell? 1

Status
Not open for further replies.

MrsNic

Instructor
Feb 6, 2005
44
GB
I have a spreadsheet about holiday bookings. If the word 'Hot' is entered I want the whole row in a range of cells to turn green. If the word 'Warm' is entered I want the whole row in a range of cells to turn orange.

I have created individual macros to change the range to the specific colour but don't know how to make it run without a button. I thought there might be a way 'IF' would work but couldn't work out the code in VB.

The 'key words' - will always be in the same column but the number of rows will change.
 


Hi, MrsNic,

You do not need ANY VBA code to do this with just TWO colors.

Excel feature Format > Conditional Formatting...

1. Make sure ALL the cells you want formatted are selected prior to

Use the Formula is: drop down. Select the first cell in the column containing your value. mMake the reference absolute to the COLUMN. You can enter up to 3 conditions.

Skip,
[glasses]Don't let the Diatribe...
talk you to death![tongue]

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Thanks for taking the time to reply to this, but I actually have four different options. I only mentioned 2 as I thought I could just replicate the answer.
 
thread68-1295894

[tt][blue]-John[/blue][/tt]
[tab][red]The plural of anecdote is not data[/red]

Help us help you. Please read FAQ 181-2886 before posting.
 



Its always best to state your requirements in total.

FOUR will work. Conditional formatting handles THREE. The FOUTH would be the "default" shading.

First shade ALL the cells with one of the four.

Then set the CF criteria/formatting for the other three.

VOLA!

Skip,
[glasses]Don't let the Diatribe...
talk you to death![tongue]

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top