Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,670
Default How to code macro for worksheet?

Does anyone have any suggesitons on how to code macro for worksheet?

Condition 1:
In cell A1, there is a number 1234, under the range between cell B2 to Z50,
if any cell matches the number 1234 in cell A1, then it's background color
should change to red and it's text color should change to white.
Condition 2:
In cell A2, there is a number 2345, under the range between cell B2 to Z50,
if any cell matches the number 2345 in cell A2, then it's background color
should change to blue and it's text color should change to white.

Condition 3:
In cell A3, ....
....

Condition 10:
In cell A10, ....
There is a priority for a list conditions,
If condition 2,3,5,6,8,10 are false, condition 1,4,7,9 are true, only change
the color for condition 1.
If condition 1,2,3,5,6,8,10 are false, condition 4,7,9 are true, only change
the color for condition 4.

I cannot use Excel build-in function to change the background and text
color, because it is limited to 3 different conditions only, but I get 10
conditions.
Does anyone have any suggestions on how to code macro for worksheet to
change the background and text color?
Thanks in advance for any suggestions
Eric
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,346
Default How to code macro for worksheet?

Hi,

Excel 2007 supports an unlimited number of conditions in the conditional
format area.

To code the colors you want for each condition turn on the recorder and
change the background and font color of a single cell, working you way
through all the combinations you want. Turn off the record.

I am not clear whether there are 10 conditions or that is just the
beginning, so your general macro will look something like this

Dim ccell As Range
Dim cell As Range

Sub ColorCells()
For Each ccell In Range("A1:A10")
For Each cell In Range("B2:Z50")
If ccell = cell Then
Color
End If
Next cell
Next ccell
End Sub

Sub Color()
Select Case ccell.Row
Case 1
cell.Interior.ColorIndex = 35
cell.Font.ColorIndex = 22
Case 2

End Select
End Sub


--
If this helps, please click the Yes button

Cheers,
Shane Devenshire


"Eric" wrote:

Does anyone have any suggesitons on how to code macro for worksheet?

Condition 1:
In cell A1, there is a number 1234, under the range between cell B2 to Z50,
if any cell matches the number 1234 in cell A1, then it's background color
should change to red and it's text color should change to white.
Condition 2:
In cell A2, there is a number 2345, under the range between cell B2 to Z50,
if any cell matches the number 2345 in cell A2, then it's background color
should change to blue and it's text color should change to white.

Condition 3:
In cell A3, ....
...

Condition 10:
In cell A10, ....
There is a priority for a list conditions,
If condition 2,3,5,6,8,10 are false, condition 1,4,7,9 are true, only change
the color for condition 1.
If condition 1,2,3,5,6,8,10 are false, condition 4,7,9 are true, only change
the color for condition 4.

I cannot use Excel build-in function to change the background and text
color, because it is limited to 3 different conditions only, but I get 10
conditions.
Does anyone have any suggestions on how to code macro for worksheet to
change the background and text color?
Thanks in advance for any suggestions
Eric

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
macro code muddan madhu Excel Discussion (Misc queries) 1 April 6th 08 03:44 PM
Macro code Shu of AZ Excel Discussion (Misc queries) 8 December 2nd 07 12:52 AM
Deleting code from a macro (by a macro) Brettjg Excel Discussion (Misc queries) 2 May 8th 07 10:14 PM
Macro code Shu of AZ Excel Discussion (Misc queries) 2 January 29th 07 06:29 PM
Macro VB code help Anthony Excel Discussion (Misc queries) 4 October 8th 05 07:25 PM


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

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"