Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Conditional Formating

Hi Guys
Can anyone help? I need some VBA code for a timeline. Specifically, I
need to be able to identify both weekends and the current date along a
horizontal timeline, with sequential dates above the timeline. It would
be nice to colour the cells containing weekends in a grey and the
current date in yellow.
Thanks

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,069
Default Conditional Formating

You don't need VBA to apply conditional formatting, but since you asked for
it, here is a macro which applies the formatting you requested. I recorded it
using cell C5. Change C5 throughout to one of the cells in your timeline. Run
the macro to format that cell, then use Format Painter to apply the same
condtional formatting to the whole timeline.

Sub ApplyCondFmt()
'Applies requested conditional formatting to cell C5.
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
Formula1:="=TODAY()"
Selection.FormatConditions(1).Interior.ColorIndex = 36 'Light yellow
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=OR(WEEKDAY(C5,1)=1, WEEKDAY(C5,1)=7)"
Selection.FormatConditions(2).Interior.ColorIndex = 15 'Light gray
End Sub

Hope this helps,

Hutch
----------------------------------
"markvdh" wrote:

Hi Guys
Can anyone help? I need some VBA code for a timeline. Specifically, I
need to be able to identify both weekends and the current date along a
horizontal timeline, with sequential dates above the timeline. It would
be nice to colour the cells containing weekends in a grey and the
current date in yellow.
Thanks


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
Conditional formating WavMaster Excel Discussion (Misc queries) 6 February 23rd 09 10:08 PM
Conditional formating Brian Excel Discussion (Misc queries) 2 December 10th 07 07:44 PM
Install dates formating using conditional formating? Jerry Eggleston Excel Discussion (Misc queries) 2 November 9th 05 05:49 PM
Help Please with Conditional FOrmating James M Excel Worksheet Functions 2 August 4th 05 09:05 AM
Conditional formating smith.james0 Excel Discussion (Misc queries) 2 July 26th 05 05:51 PM


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