Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default Assigning a cell colors via IF-THEN statements

Hello!

Can you assign a cell a specific color using an If-Then statement...instead
of using conditional formatting?

For example, if I'm evaluating a value in cell C8, which will assign a color
to cell B8 accordingly. Is this possible?

Thank you for the help!
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,942
Default Assigning a cell colors via IF-THEN statements

hi
no
formulas return values, they cannot perform actions such as assign formats.
this is one of the reasons that conditional formating was introduced. i would
concentrate on the conditional format.

Regards
FSt1

"Gravy Man" wrote:

Hello!

Can you assign a cell a specific color using an If-Then statement...instead
of using conditional formatting?

For example, if I'm evaluating a value in cell C8, which will assign a color
to cell B8 accordingly. Is this possible?

Thank you for the help!

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,388
Default Assigning a cell colors via IF-THEN statements

Hi,
If you've used up your 3 conditional formats, you'll have to revert to macros.
Having said that, if you just want to change the font colour only, you can
use a custom format.
The following is a paste from somewhere, but I can't remember where.
Apologies to the original author.

Value Font Color
===== ==========
< -100 Red
< -20 Blue
< 0 Yellow
< 20 Green
< 100 Maroon
= 100 Purple



The last three we'll leave for conditional formatting. The first three,
however, will be done using this format, which we enter by choosing
Format/Cells/Number/Custom:

[Red][<-100]General;[Blue][<-20]General;[Yellow]General;@

Of course, we don't have to use General - we could use any other numeric
format. The available color names are [BLACK], [BLUE], [CYAN], [GREEN],
[MAGENTA], [RED], [WHITE], and [YELLOW], or you can use any of the 56 colors
in the XL color palette by using [Color1] through [Color56]. Thanks, MVP Bob
Umlas for telling me about the latter method!

Regards - Dave.
  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,344
Default Assigning a cell colors via IF-THEN statements

Hi,

You could use VBA as follows:

Sub ColorCells()
Dim cell As Excel.Range
For Each cell In Selection
With cell.Interior
Select Case cell
Case Is < -10
.ColorIndex = 14
Case 0
.ColorIndex = 41
Case 1, 4, 6
.ColorIndex = 13
Case 7 To 20
.ColorIndex = 8
Case Else
.ColorIndex = 45
End Select
End With
Next cell
End Sub

This example shows how to use many of the Select Case options.
--
Cheers,
Shane Devenshire
Microsoft Excel MVP
Join http://setiathome.berkeley.edu/ and download a free screensaver to help
find life off planet earth.

"Gravy Man" wrote:

Hello!

Can you assign a cell a specific color using an If-Then statement...instead
of using conditional formatting?

For example, if I'm evaluating a value in cell C8, which will assign a color
to cell B8 accordingly. Is this possible?

Thank you for the help!

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 2003 - assigning colors to cells ohdharleyboy Excel Worksheet Functions 3 February 4th 07 05:43 PM
assigning a value to a cell Braheem Excel Worksheet Functions 3 September 13th 06 04:42 AM
if statements with colors? jkwok Excel Worksheet Functions 2 December 12th 05 09:16 PM
Assigning a value to a cell from a combox sjayar Excel Discussion (Misc queries) 3 November 2nd 05 12:58 PM
Can't format font colors or cell fill-in colors canoeron Excel Discussion (Misc queries) 3 August 22nd 05 11:46 PM


All times are GMT +1. The time now is 01:26 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"