Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Controlling formating from a function

I've written an Excel function. I'd like for it to be able to change the
formatting of the cell that it's currently in depending on the what happens
in the function. I'd like the function to be able to control the font,
interior, and pattern. I don't want to use the conditional formating feature.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default Controlling formating from a function

Functions return values. They can not modify other cells nor can they change
formatting when called from a sheet as a user defined function. If they are
called from code then they can do what they want but as a UDF they are
limited. Oddly enugh there are acouple of exceptions. They can change
comments in other cells and a couple of other weird ones (if I recall) but
not what you are looking to do.
--
HTH...

Jim Thomlinson


"Roger Starnes" wrote:

I've written an Excel function. I'd like for it to be able to change the
formatting of the cell that it's currently in depending on the what happens
in the function. I'd like the function to be able to control the font,
interior, and pattern. I don't want to use the conditional formating feature.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default Controlling formating from a function

Roger

Functions cannot change formatting.

They can only return results to the cell in which they reside.

Take another approach.......like CF?

Or event code which can change formatting depending upon value returned by a
Function.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim Num As Long
Dim rng As Range
Dim vRngInput As Variant
Set vRngInput = Intersect(Target, Range("A:A"))
If vRngInput Is Nothing Then Exit Sub
For Each rng In vRngInput
'Determine the color
Select Case rng.Value
Case Is = 1: Num = 6 'yellow
Case Is = 2: Num = 10 'green
Case Is = 3: Num = 5 'blue
Case Is = 4: Num = 3 'red
Case Is = 5: Num = 46 'orange
End Select
'Apply the color
rng.Interior.ColorIndex = Num
Next rng
End Sub


Gord Dibben Excel MVP

On Fri, 9 Dec 2005 15:05:02 -0800, "Roger Starnes" <Roger
wrote:

I've written an Excel function. I'd like for it to be able to change the
formatting of the cell that it's currently in depending on the what happens
in the function. I'd like the function to be able to control the font,
interior, and pattern. I don't want to use the conditional formating feature.

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
With a Function, how can I get rid of formating codes like <div ? AFSSkier Excel Worksheet Functions 30 June 2nd 09 06:26 PM
Conditional formating only on sum function not on =A1+A2 anil Excel Worksheet Functions 0 January 28th 09 12:15 AM
Conditional Formating or IF Function Alexa M. Excel Discussion (Misc queries) 3 July 23rd 08 04:36 PM
Conditional Formating & Rand() function BaldySlaphead Excel Discussion (Misc queries) 10 July 20th 05 03:43 PM
Copying formating and function from one Column to another poppy Excel Programming 2 July 19th 04 11:13 AM


All times are GMT +1. The time now is 12:22 AM.

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"