Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Excel 2007 - Using a Custom Function to Set Row Color

I have a little function that sets the value of a cell depending on the date
relative to a couple of other dates and a "Yes"/"No" item:

Function CurrentTaskStatus(Milestone As String, _
TaskEndDate As Date, MonthStart As Date, MonthEnd
As Date, _
TaskProj As Integer, TaskComp As Single)


If (TaskEndDate = MonthStart) And (TaskEndDate <= MonthEnd) And (Milestone
= "Yes") Then
CurrentTaskStatus = TaskComp
Else
CurrentTaskStatus = 0
End If

End Function



What I would like to do is set the color of the row in which the cell is
located to a specific color based on the conditions. I have tried things
like

rows("A45:z45).interior.color = vbBlue

with no success. Generally, a #VALUE! error appears in the cell when I try
anything that might set the color.

Am I trying to do the impossible? Or am I just way off course.

Any suggestions will be greatly appreciated!

Thanks!

Don


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default Excel 2007 - Using a Custom Function to Set Row Color

Functions return values.

They don't format cells.

Conditional Formatting is used for that.


Gord Dibben MS Excel MVP

On Sat, 21 Feb 2009 17:25:40 -0500, "Don" wrote:

I have a little function that sets the value of a cell depending on the date
relative to a couple of other dates and a "Yes"/"No" item:

Function CurrentTaskStatus(Milestone As String, _
TaskEndDate As Date, MonthStart As Date, MonthEnd
As Date, _
TaskProj As Integer, TaskComp As Single)


If (TaskEndDate = MonthStart) And (TaskEndDate <= MonthEnd) And (Milestone
= "Yes") Then
CurrentTaskStatus = TaskComp
Else
CurrentTaskStatus = 0
End If

End Function



What I would like to do is set the color of the row in which the cell is
located to a specific color based on the conditions. I have tried things
like

rows("A45:z45).interior.color = vbBlue

with no success. Generally, a #VALUE! error appears in the cell when I try
anything that might set the color.

Am I trying to do the impossible? Or am I just way off course.

Any suggestions will be greatly appreciated!

Thanks!

Don


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Excel 2007 - Using a Custom Function to Set Row Color



Gord,

My first impressions of Conditional Formatting were that it is more of a
global condition. I am looking now reading through more examples to see if
I either don't fully understand the concept or I can adapt it to my needs.

Thanks!

Don




"Gord Dibben" <gorddibbATshawDOTca wrote in message
...
Functions return values.

They don't format cells.

Conditional Formatting is used for that.


Gord Dibben MS Excel MVP

On Sat, 21 Feb 2009 17:25:40 -0500, "Don" wrote:

I have a little function that sets the value of a cell depending on the

date
relative to a couple of other dates and a "Yes"/"No" item:

Function CurrentTaskStatus(Milestone As String, _
TaskEndDate As Date, MonthStart As Date,

MonthEnd
As Date, _
TaskProj As Integer, TaskComp As Single)


If (TaskEndDate = MonthStart) And (TaskEndDate <= MonthEnd) And

(Milestone
= "Yes") Then
CurrentTaskStatus = TaskComp
Else
CurrentTaskStatus = 0
End If

End Function



What I would like to do is set the color of the row in which the cell is
located to a specific color based on the conditions. I have tried things
like

rows("A45:z45).interior.color = vbBlue

with no success. Generally, a #VALUE! error appears in the cell when I

try
anything that might set the color.

Am I trying to do the impossible? Or am I just way off course.

Any suggestions will be greatly appreciated!

Thanks!

Don




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default Excel 2007 - Using a Custom Function to Set Row Color

CF can be used on one cell or a range of cells.

Simple example................

Select A45:Z45 and CFFormula is: =$A$45="condition" where "condition" is
your desired criterion.

Format to Blue Pattern.

When A45 meets the condition, A45:Z45 will be colored blue.

Note the $ signs to fix A45 as the trigger cell.


Gord

On Sun, 22 Feb 2009 11:50:32 -0500, "Don" wrote:



Gord,

My first impressions of Conditional Formatting were that it is more of a
global condition. I am looking now reading through more examples to see if
I either don't fully understand the concept or I can adapt it to my needs.

Thanks!

Don




"Gord Dibben" <gorddibbATshawDOTca wrote in message
.. .
Functions return values.

They don't format cells.

Conditional Formatting is used for that.


Gord Dibben MS Excel MVP

On Sat, 21 Feb 2009 17:25:40 -0500, "Don" wrote:

I have a little function that sets the value of a cell depending on the

date
relative to a couple of other dates and a "Yes"/"No" item:

Function CurrentTaskStatus(Milestone As String, _
TaskEndDate As Date, MonthStart As Date,

MonthEnd
As Date, _
TaskProj As Integer, TaskComp As Single)


If (TaskEndDate = MonthStart) And (TaskEndDate <= MonthEnd) And

(Milestone
= "Yes") Then
CurrentTaskStatus = TaskComp
Else
CurrentTaskStatus = 0
End If

End Function



What I would like to do is set the color of the row in which the cell is
located to a specific color based on the conditions. I have tried things
like

rows("A45:z45).interior.color = vbBlue

with no success. Generally, a #VALUE! error appears in the cell when I

try
anything that might set the color.

Am I trying to do the impossible? Or am I just way off course.

Any suggestions will be greatly appreciated!

Thanks!

Don




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Excel 2007 - Using a Custom Function to Set Row Color


Gord,

Do you know of any VBA examples? If so, would you post the link(s)?

Thanks!

Don



"Gord Dibben" <gorddibbATshawDOTca wrote in message
...
CF can be used on one cell or a range of cells.

Simple example................

Select A45:Z45 and CFFormula is: =$A$45="condition" where "condition"

is
your desired criterion.

Format to Blue Pattern.

When A45 meets the condition, A45:Z45 will be colored blue.

Note the $ signs to fix A45 as the trigger cell.


Gord

On Sun, 22 Feb 2009 11:50:32 -0500, "Don" wrote:



Gord,

My first impressions of Conditional Formatting were that it is more of a
global condition. I am looking now reading through more examples to see

if
I either don't fully understand the concept or I can adapt it to my

needs.

Thanks!

Don




"Gord Dibben" <gorddibbATshawDOTca wrote in message
.. .
Functions return values.

They don't format cells.

Conditional Formatting is used for that.


Gord Dibben MS Excel MVP

On Sat, 21 Feb 2009 17:25:40 -0500, "Don"

wrote:

I have a little function that sets the value of a cell depending on

the
date
relative to a couple of other dates and a "Yes"/"No" item:

Function CurrentTaskStatus(Milestone As String, _
TaskEndDate As Date, MonthStart As Date,

MonthEnd
As Date, _
TaskProj As Integer, TaskComp As Single)


If (TaskEndDate = MonthStart) And (TaskEndDate <= MonthEnd) And

(Milestone
= "Yes") Then
CurrentTaskStatus = TaskComp
Else
CurrentTaskStatus = 0
End If

End Function



What I would like to do is set the color of the row in which the cell

is
located to a specific color based on the conditions. I have tried

things
like

rows("A45:z45).interior.color = vbBlue

with no success. Generally, a #VALUE! error appears in the cell when

I
try
anything that might set the color.

Am I trying to do the impossible? Or am I just way off course.

Any suggestions will be greatly appreciated!

Thanks!

Don






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
custom function color art Excel Programming 3 November 16th 08 05:43 PM
Migrating Custom color palette from 2003 to 2007 Wenster Excel Discussion (Misc queries) 0 September 26th 08 02:33 PM
Want to add help file for custom function but excel 2007 is flaked Sabotuer99 Excel Worksheet Functions 1 July 19th 08 01:46 PM
Need help w using custom image for custom toolbar in Excel 2007 vbaexperimenter Excel Programming 10 June 23rd 08 06:05 PM
Powerpoint / Excel: custom pp RGB color doesn't match identical Excelcustom RGB color mikewillnot Charts and Charting in Excel 1 February 26th 08 05:22 PM


All times are GMT +1. The time now is 03:41 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"