#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 63
Default Macro Help

I need to set a Macro (possibly in VBA) that will change the color of a
selected number of cells based on the text in another cell.

For example:

When A1 states - FI the row turns orange
When A1 states - ALJ the row turns green
etc.

Since I need to do this to many rows is there also a way to set this by
column rather than cell text?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Macro Help

Yea you can do it,

if you comfortable wiht coding tey using for each loop with each row, or you
can loop through cells like you doing and select the entire row and then
change the color of the row.

I guess it might work
Anand.V.V.N


--
"Who will guard the guards?"


"akemeny" wrote:

I need to set a Macro (possibly in VBA) that will change the color of a
selected number of cells based on the text in another cell.

For example:

When A1 states - FI the row turns orange
When A1 states - ALJ the row turns green
etc.

Since I need to do this to many rows is there also a way to set this by
column rather than cell text?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Macro Help

This macro will do what you asked...

Sub ChangeRowColors()
Dim C As Range
For Each C In Selection
Select Case UCase(C.Value)
Case "FI"
ColorVal = 45 ' ColorIndex for Orange
Case "ALJ"
ColorVal = 50 ' ColorIndex for a shade of Green
'
' Add additional Case statements for your other
' codes here (always use upper case for the codes).
'
Case Else
ColorVal = xlNone
End Select
C.EntireRow.Interior.ColorIndex = ColorVal
Next
End Sub

Just add the additional Case statements where indicated. The numbers that
are being assigned inside the Case statements are ColorIndex values.

--
Rick (MVP - Excel)


"akemeny" wrote in message
...
I need to set a Macro (possibly in VBA) that will change the color of a
selected number of cells based on the text in another cell.

For example:

When A1 states - FI the row turns orange
When A1 states - ALJ the row turns green
etc.

Since I need to do this to many rows is there also a way to set this by
column rather than cell text?


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 to copy and paste values (columns)I have a macro file built C02C04 Excel Programming 2 May 2nd 08 01:51 PM
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
Macro not showing in Tools/Macro/Macros yet show up when I goto VBA editor [email protected] Excel Programming 2 March 30th 07 07:48 PM
how to count/sum by function/macro to get the number of record to do copy/paste in macro tango Excel Programming 1 October 15th 04 01:16 PM
Start Macro / Stop Macro / Restart Macro Pete[_13_] Excel Programming 2 November 21st 03 05:04 PM


All times are GMT +1. The time now is 02:46 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"