LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default CF or VBA

In this example the formulae in column AB will return "G" or "O" or "R" for
green or orange or red. It is event code to be inserted in the worksheet
code area:

Private Sub Worksheet_Calculate()
Dim n As Long
n = Cells(Rows.Count, "AB").End(xlUp).Row
For i = 1 To n
codee = Cells(i, "AB").Value
Select Case codee
Case "G"
clr = 10
Case "O"
clr = 46
Case "R"
clr = 3
Case Else
clr = xlNone
End Select
With Cells(i, "AB").EntireRow
.Interior.ColorIndex = clr
End With
Next
End Sub


Because it is worksheet code, it is very easy to install and use:

1. right-click the tab name near the bottom of the window
2. select View Code - this brings up a VBE window
3. paste the stuff in and close the VBE window

If you save the workbook, the macro will be saved with it.

To remove the macro:

1. bring up the VBE windows as above
2. clear the code out
3. close the VBE window

To learn more about macros in general, see:

http://www.mvps.org/dmcritchie/excel/getstarted.htm

To learn more about Event Macros (worksheet code), see:

http://www.mvps.org/dmcritchie/excel/event.htm


--
Gary''s Student - gsnu200852


"Jock" wrote:

In a sheet with (max)10000 rows, any of the rows could be shaded green(when
criteria 1 is met), orange (criteria 2), or red (3).
The criteria will appear in column "AB" by formula e.g. =IF($S410,"W","").
This formula will change as I add bits to it but the premise is that the code
needs to look at column AB and deal with whatever result is displayed by the
formula (max of 3.
If the criteria in any cell in "AB" alters or is removed entirely, the row
will need to reflect this.
How would I do this by code?


--
Traa Dy Liooar

Jock

 
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



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

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"