View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
JLGWhiz JLGWhiz is offline
external usenet poster
 
Posts: 3,986
Default Setting a cell format based on a function operation

You would need a cell reference to add the color. I don't know how your
code is written to identify the cell where the value goes, i.e. as a
variable, or a specified cells or A1 reference. If you are using select or
activate to get to the cell, then
ActiveCell.Interior.ColorIndex = ? would work in the case statement.
Otherwise, use the actual range/cells reference.

"scott56hannah" wrote:

Hi,

I am trying to setup a basic invoice sheet and I have started a function
that will
calculate the number of days owing based on the current date and the date of
the invoice.....it sets a value as per below for a cell in the invoice row

Function strDebtorDays(intDebtorDays As Integer) As String
'This function will return a string value showing the number of days that
the debt has been owed

Select Case intDebtorDays

Case 0 To 7
strDebtorDays = "< 7 days"
Case 8 To 14
strDebtorDays = "< 14 days"
Case 15 To 30
strDebtorDays = "< 30 days"
Case 31 To 60
strDebtorDays = "< 60 days"
Case 61 To 90
strDebtorDays = "< 90 days"
Case Is 90
strDebtorDays = " 90 days"
Case Else
strDebtorDays = "Not Valid Range"

End Select

End Function

I now want to color the interior of the cell based on one of those values.
But because it is function I cannot work out how to update the cell format ?

Any help appreciated

Thanks
Scott