Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
PPM at Brackmills
 
Posts: n/a
Default Format a column in a table based on the date

I have a table with the top row formatted as the dates for the given days. I
want a script or makro which looks for todays date, then highlights the
respective column in the table either with a bold border or with color.
  #2   Report Post  
Posted to microsoft.public.excel.misc
Kevin Vaughn
 
Posts: n/a
Default Format a column in a table based on the date

Try conditional formatting with formula is =D$1=TODAY()
Note: I haven't tested this other than just now, but it works today.
--
Kevin Vaughn


"PPM at Brackmills" wrote:

I have a table with the top row formatted as the dates for the given days. I
want a script or makro which looks for todays date, then highlights the
respective column in the table either with a bold border or with color.

  #3   Report Post  
Posted to microsoft.public.excel.misc
Kevin B
 
Posts: n/a
Default Format a column in a table based on the date

The following macro uses row 1 of sheet1 as its starting point and assumes
that there are no blank columns between the first and last data column. You
can insert the code into a general module.
================================================== ====
Sub ColorMyDay()

Dim wb As Workbook
Dim ws As Worksheet
Dim dt As Date
Dim i As Integer
Set wb = ActiveWorkbook
Set ws = wb.Sheets("Sheet1")

ws.Activate
Range("A1").Select

Selection.CurrentRegion.Select
Selection.Interior.ColorIndex = xlNone

dt = ActiveCell.Value

Do Until dt = 0
If dt = Date Then
i = ActiveCell.Column
Range(Selection, Selection.End(xlDown)).Select
With Selection.Interior
.ColorIndex = 37
.Pattern = xlSolid
End With
dt = 0
End If
ActiveCell.Offset(0, 1).Select
dt = ActiveCell.Value
Loop

Cells(1, i).Select

Set wb = Nothing
Set ws = Nothing

End Sub
================================================== ====
--
Kevin Backmann


"PPM at Brackmills" wrote:

I have a table with the top row formatted as the dates for the given days. I
want a script or makro which looks for todays date, then highlights the
respective column in the table either with a bold border or with color.

  #4   Report Post  
Posted to microsoft.public.excel.misc
daddylonglegs
 
Posts: n/a
Default Format a column in a table based on the date


You could do it without a macro using conditional formatting

select whole table with A1 active cell, assuming top left cell of table
is A1 (adjust accordingly if not) use

Format Conditional Formatting formula is

=A$1=TODAY()

select desired formatting


--
daddylonglegs
------------------------------------------------------------------------
daddylonglegs's Profile: http://www.excelforum.com/member.php...o&userid=30486
View this thread: http://www.excelforum.com/showthread...hreadid=512886

  #5   Report Post  
Posted to microsoft.public.excel.misc
PPM at Brackmills
 
Posts: n/a
Default Format a column in a table based on the date

Kevin

Many thanks but being a newbie to VBA I can't get it to work. The sheet is
called report, the range of the table is C4-I27, row 4 has the date. Am I
asking too much for you to tailor your code for me. And then, and this is a
bit embarassing, explain how I get this into the workbook and get it to run
when the spreadsheet is opened.

Hope you can help

Mark



"Kevin B" wrote:

The following macro uses row 1 of sheet1 as its starting point and assumes
that there are no blank columns between the first and last data column. You
can insert the code into a general module.
================================================== ====
Sub ColorMyDay()

Dim wb As Workbook
Dim ws As Worksheet
Dim dt As Date
Dim i As Integer
Set wb = ActiveWorkbook
Set ws = wb.Sheets("Sheet1")

ws.Activate
Range("A1").Select

Selection.CurrentRegion.Select
Selection.Interior.ColorIndex = xlNone

dt = ActiveCell.Value

Do Until dt = 0
If dt = Date Then
i = ActiveCell.Column
Range(Selection, Selection.End(xlDown)).Select
With Selection.Interior
.ColorIndex = 37
.Pattern = xlSolid
End With
dt = 0
End If
ActiveCell.Offset(0, 1).Select
dt = ActiveCell.Value
Loop

Cells(1, i).Select

Set wb = Nothing
Set ws = Nothing

End Sub
================================================== ====
--
Kevin Backmann


"PPM at Brackmills" wrote:

I have a table with the top row formatted as the dates for the given days. I
want a script or makro which looks for todays date, then highlights the
respective column in the table either with a bold border or with color.

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
Copy Color Formats Based On Column Date Values Naji Excel Discussion (Misc queries) 0 January 11th 06 09:06 PM
creating a bar graph Johnfli Excel Discussion (Misc queries) 0 October 26th 05 08:16 PM
Format cell in column B based on value in the next cell (column c) Nicole Excel Discussion (Misc queries) 7 May 18th 05 10:19 PM
Adding a column based on greater than a date Toni G. Excel Worksheet Functions 4 March 17th 05 08:06 PM
LINK ONE ROW BASED ON CONTENTS OF A COLUMN WITHIN THE ROW (DATE) Susan Excel Worksheet Functions 0 February 16th 05 05:01 PM


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