Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
dsg dsg is offline
external usenet poster
 
Posts: 1
Default different cellcolor depending on cellvalue

I would like to set the color of the different cells depending on
what value that is in the cell.

Let's say, it should search in the range ("A1:H40") and
depending on what number it is in each field it get different
cellcolor.
ex. if the cell A5 = 50 it should get a blue background.



Any suggestions ?
All this is going to run inside a macro

--
Message posted from http://www.ExcelForum.com

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default different cellcolor depending on cellvalue

Hi

here's one way:

Sub populate()
Range("a1").Select
For i = 0 To 7
For j = 0 To 39
ActiveCell.Offset(j, i) = Int((15 * Rnd) + 1)
Next j
Next i


For i = 0 To 7
For j = 0 To 39
Select Case ActiveCell.Offset(j, i).Value
Case 1 To 5
ActiveCell.Offset(j, i).Font.ColorIndex = 3
Case 6 To 10
ActiveCell.Offset(j, i).Font.ColorIndex = 5
Case 11 To 15
ActiveCell.Offset(j, i).Font.ColorIndex = 1
End Select
Next j
Next i


if you copy and paste this into the VB for sheet1 in a new
worksheet it should work. The first thing it does is
populate the range you mentioned (A1:H40) with random
numbers. Then it analyses each number and assigns it a
different colour depending on it value as defined in the
case loop. Hope it helps.

Peter
End Sub



-----Original Message-----
I would like to set the color of the different cells

depending on
what value that is in the cell.

Let's say, it should search in the range ("A1:H40") and
depending on what number it is in each field it get

different
cellcolor.
ex. if the cell A5 = 50 it should get a blue background.



Any suggestions ?
All this is going to run inside a macro.


---
Message posted from http://www.ExcelForum.com/

.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default different cellcolor depending on cellvalue

excellent Peter, that helped....thans

--
Message posted from http://www.ExcelForum.com

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
how do i update filter in a pivottable based on a cellvalue? Michael Murphy Excel Discussion (Misc queries) 0 February 8th 10 03:05 PM
sum a value depending on the value of a cell?? UKMAN Excel Worksheet Functions 18 February 27th 08 05:00 PM
transpose horizantal basing on cellvalue balu Excel Discussion (Misc queries) 1 February 10th 08 11:43 PM
Return a value, depending on particular day Q Sean Excel Worksheet Functions 3 February 7th 08 03:40 PM
Different validation list based on cellvalue on the left BKO Excel Worksheet Functions 2 June 8th 07 03:24 PM


All times are GMT +1. The time now is 04:04 AM.

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

About Us

"It's about Microsoft Excel"