Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default VBA for Dates and Row Colors

Hello,

I need help writing the VBA code to acomplish the
following: I need to find any date in a spreadsheet that
is <= 90 days old; then I want to change the back color of
the row to yellow for those dates. For example if I had
the following data:
Name Acct# AcctCloseDate
This Guy 123456 01/01/2004
That Guy 654321 10/15/2004
Since the first date is over 10 months old (way past 90
days) I would leave the row as it is. Since the second
date is only 6 days old I would want to change the whole
row or at least the cell contaning that date to yellow.
Any help with a solution will be greatly appreciated.
Thank you.

Dave Y
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default VBA for Dates and Row Colors

On Thu, 21 Oct 2004 12:42:06 -0700, "Dave Y"
wrote:

Hello,

I need help writing the VBA code to acomplish the
following: I need to find any date in a spreadsheet that
is <= 90 days old; then I want to change the back color of
the row to yellow for those dates. For example if I had
the following data:
Name Acct# AcctCloseDate
This Guy 123456 01/01/2004
That Guy 654321 10/15/2004
Since the first date is over 10 months old (way past 90
days) I would leave the row as it is. Since the second
date is only 6 days old I would want to change the whole
row or at least the cell contaning that date to yellow.
Any help with a solution will be greatly appreciated.
Thank you.

Dave Y


Well, you do it with conditional formatting which can also be done via the
worksheet.

I recorded a macro to do the conditional formatting to generate some VBA code.
I assumed your data was in A2:G100 but you can change this and highlight more
or fewer columns and format more or fewer rows.

I assumed your AcctCloseDate was in column C.

=================================
Sub CF()

[a2].Activate
With Range("A2:G100")
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=$C2(TODAY()-90)"
With Range("A2:G100").FormatConditions(1).Font
.Bold = True
.Italic = False
.ColorIndex = 2
End With
.FormatConditions(1).Interior.ColorIndex = 3
End With
End Sub
=======================


--ron
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default VBA for Dates and Row Colors

Hi Ron,

Thanks for your quick reply. I'll try your code or take your suggestion of
using conditional formatting tomorrow when I'm back at work. Thanks again.

Dave Y

"Ron Rosenfeld" wrote:

On Thu, 21 Oct 2004 12:42:06 -0700, "Dave Y"
wrote:

Hello,

I need help writing the VBA code to acomplish the
following: I need to find any date in a spreadsheet that
is <= 90 days old; then I want to change the back color of
the row to yellow for those dates. For example if I had
the following data:
Name Acct# AcctCloseDate
This Guy 123456 01/01/2004
That Guy 654321 10/15/2004
Since the first date is over 10 months old (way past 90
days) I would leave the row as it is. Since the second
date is only 6 days old I would want to change the whole
row or at least the cell contaning that date to yellow.
Any help with a solution will be greatly appreciated.
Thank you.

Dave Y


Well, you do it with conditional formatting which can also be done via the
worksheet.

I recorded a macro to do the conditional formatting to generate some VBA code.
I assumed your data was in A2:G100 but you can change this and highlight more
or fewer columns and format more or fewer rows.

I assumed your AcctCloseDate was in column C.

=================================
Sub CF()

[a2].Activate
With Range("A2:G100")
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=$C2(TODAY()-90)"
With Range("A2:G100").FormatConditions(1).Font
.Bold = True
.Italic = False
.ColorIndex = 2
End With
.FormatConditions(1).Interior.ColorIndex = 3
End With
End Sub
=======================


--ron

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default VBA for Dates and Row Colors

On Thu, 21 Oct 2004 18:09:02 -0700, Dave Y
wrote:

Hi Ron,

Thanks for your quick reply. I'll try your code or take your suggestion of
using conditional formatting tomorrow when I'm back at work. Thanks again.


You're welcome. Let me know if any problems.


--ron
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
Dates changing colors JAS Excel Worksheet Functions 2 March 30th 10 12:08 AM
Used drawing colors in shapes....lost default colors for "Fill Col Lai704 Excel Discussion (Misc queries) 1 August 20th 08 04:45 AM
Worksheet formatting (fill colors & text colors) disappeared sweettooth Excel Discussion (Misc queries) 2 June 24th 08 01:16 AM
Lost highlighting and font colors; background colors on web pages Jan in Raleigh Excel Discussion (Misc queries) 2 July 31st 07 09:10 PM
Changing cell colors to correspond to different dates emtp6738 Excel Worksheet Functions 2 September 26th 06 02:40 AM


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