Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 51
Default Formatting not updating inside a function

Hi,

I have developed a basic function that will include a string value to a cell
and then format that cell's background. The string value goes in ok but the
format of the cell's background does not work. If I extract the format code
into it's own macro it updates the cell contents without a problem....can
anyone suggest where I am going wrong ?

Cell has the following values to call the function
=strDebtorDays(H5,ADDRESS(ROW(),COLUMN()))
Where H5 is 7

Function strDebtorDays(intDebtorDays As Integer, strCellReference As String)
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"

'Update the formating of the cell we are referencing
Range(strCellReference).Select
With Selection.Interior
.ColorIndex = 6
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With

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



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Formatting not updating inside a function

UDFs called from the worksheet can't change cell format (just as with
built-in functions).

To change format, you'd need to use an event macro instead.

In article ,
scott56hannah wrote:

can
anyone suggest where I am going wrong ?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 51
Default Formatting not updating inside a function

Was the article below supposed to be a link ? if it was it did not come through

Scott

"JE McGimpsey" wrote:

UDFs called from the worksheet can't change cell format (just as with
built-in functions).

To change format, you'd need to use an event macro instead.

In article ,
scott56hannah wrote:

can
anyone suggest where I am going wrong ?


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Formatting not updating inside a function

Yes, it's a link, but it's probably irrelevant to you - it's the
reference to your original article.

In article ,
scott56hannah wrote:

Was the article below supposed to be a link ? if it was it did not come
through

Scott

"JE McGimpsey" wrote:

UDFs called from the worksheet can't change cell format (just as with
built-in functions).

To change format, you'd need to use an event macro instead.

In article ,
scott56hannah wrote:

can
anyone suggest where I am going wrong ?


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
INDIRECT function inside AND function Biff Excel Worksheet Functions 3 September 23rd 06 07:20 PM
match function inside if function gnotnoel Excel Programming 2 June 1st 06 07:44 PM
Nesting Networkdays function inside and If function Addison Excel Worksheet Functions 2 April 13th 06 08:04 PM
SUMIF Function Inside SUMPRODUCT Function Abdul Waheed Excel Worksheet Functions 17 September 19th 05 04:24 PM
Find and Replace formatting inside of a macro mlstjohn Excel Programming 0 November 11th 04 04:16 PM


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