LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VBA & Conditional Formatting 3 conditions

Hi

I've created a calendar using a VLOOKUP which shows key meetings and
events. I would like to colour code these, which I have done using
VBA, but I find that unless you physically go into the cell and press
return, the VBA code doesn't change the cell format.

My code is

Set rng = Intersect(Target, Range("weekcal"))
If rng Is Nothing Then
Exit Sub
Else
Dim cl As Range
For Each cl In rng
On Error Resume Next
' -- The line above won't change the cell's background
' -- color if the cell's value is not found in the range
' -- that we specified (rngcolors).
cl.Interior.ColorIndex = _
Application.WorksheetFunction.VLookup(cl.Value _
, ThisWorkbook.Sheets("Sheet2").Range("rngColours"), 2,
False)

If Err.Number < 0 Then
'cl.Interior.ColorIndex = xlNone
cl.Interior.ColorIndex = 2
End If
Next cl
End If

End Sub

Where I have created a range called "rngColours" and placed the
background colour and font colour in.

I have looked through some of the news groups and saw Tom Ogilvy's
reply to Todd Huttenstine using

DIM cell as Range, res as Variant
Worksheets(3).Activate
For each cell in worksheets(3).range("A5:A100")
res = Application.Vlookup(Cell.Value,_
Worksheets(4).Range("M2:Q100"),4,False
etc

I am very new to VBA and would like to know how I could incorporate
this into my code so when a drop down menu is chosen (to choose the
month) and the data changes, the background colour and font will also
change (without having to go into the cell and hit return).

Any help gratefully recieved.

Merry Christmas!

DeeCee

 
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
Conditional Formatting for 4 conditions Steve Excel Worksheet Functions 2 March 11th 10 09:13 PM
Conditional Formatting - 2 conditions LorrieM Excel Discussion (Misc queries) 2 May 22nd 09 03:28 PM
2 conditions using conditional formatting jimar Excel Discussion (Misc queries) 3 March 8th 07 01:24 PM
Conditional formatting should allow more than three conditions. Joshua, Technical Editor Excel Discussion (Misc queries) 1 July 26th 06 12:44 PM
Conditional Formatting on more than "4" Conditions belly0fdesire Excel Discussion (Misc queries) 1 September 1st 05 10:41 PM


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