MrExcel Message Board

Go Back   MrExcel Message Board > Question Forums > Excel Questions

Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only.

Reply
 
Thread Tools Display Modes
Old Apr 4th, 2002, 08:19 PM   #1
Owen Kenny
New Member
 
Join Date: Apr 2002
Posts: 4
Default

I am trying to colour individual cells in a large section of a worksheet,20 columns by 600 rows so that there are up to 10 different colours dependent on the value in each cell.
As I work on the sheet the values in the cells change and I need the colours to change as I go. Conditional formatting works just fine but there are not enough values available (3 choices only). Is it possible to add more choices. I am very limited in VB ability.
Yours hopefully Owen Kenny
Owen Kenny is offline   Reply With Quote
Old Apr 4th, 2002, 08:31 PM   #2
Tom Urtis
MrExcel MVP
 
Tom Urtis's Avatar
 
Join Date: Feb 2002
Location: San Francisco, California USA
Posts: 10,388
Default

Yes it is possible, a few questions:

(1) What is your range of cells?
(2) What is your range of values for each color? Example, 0 - 50 would be yellow, 51 - 100 would be green, etc.
(3) Are the values being added manually or are they calculated as the result of formulas in those cells?

Answer these questions and we can assist more efficiently.

__________________
Tom Urtis
Microsoft MVP - Excel
Tom Urtis is offline   Reply With Quote
Old Apr 4th, 2002, 10:44 PM   #3
robfo0
Board Regular
 
Join Date: Feb 2002
Location: Stockton, California
Posts: 281
Default

also, try doing a search on this board for conditional formatting, i know its been answered before
robfo0 is offline   Reply With Quote
Old Apr 4th, 2002, 10:58 PM   #4
Owen Kenny
New Member
 
Join Date: Apr 2002
Posts: 4
Default

Currently I am using this macro but it does not update until I run the macro and I am using it repearedly and the time wasted is terrible.
This contains the ranges and the colours I am currently using.
The values change as a result of formulas in the cells.
Thank you very much for your help.
OK
Sub Rainbowchange()
For x = 10 To 570
For y = 57 To 68
With Worksheets("Sheet1").Cells(x, y)
Select Case .Value

Case Is > 2
.Interior.Color = RGB(11, 165, 11)

Case Is > 1.6
.Interior.Color = RGB(14, 214, 14)
Case Is > 1.2
.Interior.Color = RGB(58, 242, 58)
Case Is > 0.8
.Interior.Color = RGB(129, 247, 129)
Case Is > 0.4
.Interior.Color = RGB(199, 251, 199)
Case Is > 0.2
.Interior.Color = RGB(255, 255, 149)

Case Is > 0
.Interior.Color = RGB(255, 255, 195)
Case Is = 0
.Interior.Color = RGB(255, 255, 255)
Case Is > -0.2
.Interior.Color = RGB(252, 224, 224)
Case Is > -0.4
.Interior.Color = RGB(249, 189, 189)
Case Is > -0.8
.Interior.Color = RGB(245, 143, 143)
Case Is > -1.2
.Interior.Color = RGB(241, 101, 101)
Case Is > -1.6
.Interior.Color = RGB(238, 70, 70)
Case Is > -2
.Interior.Color = RGB(235, 27, 27)
Case Is < -1.99
.Interior.Color = RGB(254, 18, 18)
End Select
End With
Next y
Next x
End Sub
Owen Kenny is offline   Reply With Quote
Old Apr 4th, 2002, 11:35 PM   #5
Tom Schreiner
Board Regular
 
Join Date: Mar 2002
Location: Cincinnati, Ohio, USA
Posts: 6,824
Default

I'm assuming the values in these cells are changed via links to other cells?
The easiest way to accomplish what you are trying to do might be to have direct control over the assigning of values to these cells.

Create a procedure with your select case statements, but no looping, and pass the value to this procedure. Pass the value of the cell and the address of the cell to be formatted. In other words, format the cells in sheet1 from the change event in sheet2.

Do you understand?

You also could pass place your code, as is, in the worksheet calculate event and run your code everytime a cells value is changed
via calculation.

Try it

Tom
Tom Schreiner is offline   Reply With Quote
Old Apr 5th, 2002, 12:01 AM   #6
robfo0
Board Regular
 
Join Date: Feb 2002
Location: Stockton, California
Posts: 281
Default

I found this code from a quick search of this board, guess whos code it was, the notorious TsTom It is a previous response to your exact question and uses the method he describes above

i changed the rows and columns to what you wanted them to be.

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Target.Row > 9 And Target.Row < 570 And Target.Column > 56 And Target.Column < 69 Then
With Target
Select Case .Value

Case Is > 2
.Interior.Color = RGB(11, 165, 11)
Case Is > 1.6
.Interior.Color = RGB(14, 214, 14)
Case Is > 1.2
.Interior.Color = RGB(58, 242, 58)
Case Is > 0.8
.Interior.Color = RGB(129, 247, 129)
Case Is > 0.4
.Interior.Color = RGB(199, 251, 199)
Case Is > 0.2
.Interior.Color = RGB(255, 255, 149)

Case Is > 0
.Interior.Color = RGB(255, 255, 195)
Case Is = 0
.Interior.Color = RGB(255, 255, 255)
Case Is > -0.2
.Interior.Color = RGB(252, 224, 224)
Case Is > -0.4
.Interior.Color = RGB(249, 189, 189)
Case Is > -0.8
.Interior.Color = RGB(245, 143, 143)
Case Is > -1.2
.Interior.Color = RGB(241, 101, 101)
Case Is > -1.6
.Interior.Color = RGB(238, 70, 70)
Case Is > -2
.Interior.Color = RGB(235, 27, 27)
Case Is < -1.99
.Interior.Color = RGB(254, 18, 18)
End Select
End With
End If

End Sub


robfo0 is offline   Reply With Quote
Old Apr 5th, 2002, 01:12 AM   #7
Owen Kenny
New Member
 
Join Date: Apr 2002
Posts: 4
Default

Thanks very much for the ideas . I'll give them a go and see if I can understand what's going on .
Owen Kenny is offline   Reply With Quote
Old Apr 5th, 2002, 07:59 PM   #8
Owen Kenny
New Member
 
Join Date: Apr 2002
Posts: 4
Default

I'm afraid I can't follow this . My VB is not good and I had help with the original macro. I have modified it but am not able to develop my own. I'll try to clarify what I am doing.At the moment each worksheet is a separate entity and the cells within the range specified are deriving their value from cells outside the range but on the same worksheet.
Each column within the range has a formula in it and all of the cells in the column have the same formula but different values depending on their data sources. At the moment I am changing the formulas constantly trying to develop the magic formula that does exactly what I want. Each time I alter a formula the values in all cells within the column change and so their colours need to change .The macro I was using works well but is incredibly slow. Can I use the modifications suggested using Target to create a macro that will work much more quickly than the one I have been using.Looks like I'll have to do a lot more work on VB.I've looked at the other conditional formatting topics but I can't find one doing what I am after. If there is one and I'm missing it could you please let me know which page or date it is on and under what search topic.
Thanks very much for the efforts.
OK
Owen Kenny is offline   Reply With Quote
Old Apr 5th, 2002, 08:26 PM   #9
Tom Schreiner
Board Regular
 
Join Date: Mar 2002
Location: Cincinnati, Ohio, USA
Posts: 6,824
Default

Hey Ken
If you'd like, send me a copy of your sheet.
TsTom@hotmail.com
Tom
Tom Schreiner is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 01:36 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
All contents Copyright 1998-2012 by MrExcel Consulting.
diabetic desserts recipes recipes Diabetic Soups Holiday Pizza Recipes Popcorn Recipes Recipes For Microwave Pasta Recipes Casserole Recipes Chili Recipes Curry Recipes Crockpot Recipes Apples Recipes Bread Recipes Vegetarian Recipes Vegetable recipes Desserts Recipes Appetizers Ethnic Recipes Meat Dishes Barbecue Recipes Sauces Recipes Marinade Recipes Low Fat Recipes Frugal Gourmet Kitchen Classics Recipes On The Grill Cook Books Seafood Recipes Cajun Recipes Breads Low Fat Low Fat Breads Bread Machine Recipes Yeast Breads Quick Breads Fat Free Vegetarian Salad Recipes Eggplant Recipes Radish Recipes Tomato Recipes Jalapeno Recipes Potato Recipes Lettuce Recipes Cabbage Recipes Beans Ambrosia Recipes Biscotti Recipes Desserts Low Fat Cookie Recipes Cheesecake Recipes Cake Recipes Pie Recipes Muffin Recipes Custard Recipes Best Appetizers Appetizers Low Fat Salsa Recipes Dip Recipes International Recipes Afghan Recipes Alaska Recipes French Recipes German Recipes Greek Recipes Italian Recipes Spanish Recipes Thai Recipes Korean Recipes Chinese Recipes Mexican Recipes Indian Recipes Beef Recipes Pork Pork & Ham Pork Butts Pork Chop Recipes Pork Ribs Rulled Pork Poultry Recipes Stews Recipes Ground Beef Barbecue Grill Barbecue Smoker All Purpose Sauce BBQ Sauce Barbecue Sauce Carolina BBQ Sauce Pickle Recipes Marinades Smoking Low Fat Appetizers & Dips Low Fat Breakfast Low Fat Cakes Low Fat Cheesecakes Low Fat Cookies Low Fat Desserts Low Fat Fish & Seafood Low Fat Meats Low Fat Pasta Low Fat Pies Low Fat Salads Low Fat Sandwiches Low Fat Sauces & Condiments Low Fat Sides Low Fat Soups Low Fat Vegetarian Baker's Dozen Taste of Home Recipe Book Bon Appetit Cookbook Blacktie Cookbook Buster Cook Book Cookbook USA Cook Book Cook Book Sara's Cookbook Sara's Cookbook Appetizers and Dips Poultry recipes Diabetic recipes Holiday recipes Miscellaneous recipes 110 recipes 1986 Usenet cookbook 2900 recipes Cyberrealm recipes Great sysops of world Specialty recipes Ceideburg recipes Cheese recipes Chili recipes Fruits recipes Garlic recipes Great chefs of NY Londontowne recipes Raisins recipes Recipes for kids US Food Vegetarian recipes Bread recipes Drinks Meat Dishes Brisket recipes Caribou recipes Chicken recipes Filet mignons recipes Pork recipes Swordfish recipes Turkey recipes Pasta recipes Uncategorized recipes Ethnic recipes Canada recipes English recipes Ethiopia recipes Germany recipes Greece recipes Mexican recipes Philippines recipes Welsh recipes Microwave recipes Soups recipes Vegetable recipes Asparagus recipes Barley recipes Brown rice recipes Lentil recipes Mushrooms recipes Salads recipes Wild rice Desserts recipes Cakes recipes Chocolate recipes Cookies recipes Ice cream recipes