LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 620
Default User defined function & formatting

Jonas,

No you cannot modify format from within a function, simply return a value.

Why is CF not sufficient. Is it because it only has 3 conditions? If so, you
could use event code liek this

Private Sub Worksheet_Change(By Target As Range)
Application.EnableEvents = False
On Error GoTo ws_exit:
If (Not Intersect(Target, Range("colours")) Is Nothing) Then
Select Case Target.Value
Case "a": Target.Interior.ColorIndex = 3
Case "b": Target.Interior.ColorIndex = 4
Case "c": Target.Interior.ColorIndex = 34
Case "d": Target.Interior.ColorIndex = 35
etc.
End Select
End If

ws_exit:
Application.EnableEvents = True
End Sub

--

HTH

Bob Phillips

"Jonas Caspersson" wrote in message
...
Hi, i have a Excel question.

Is it possible to from within a user defined function (VBA) modify the

cells
properties, like .interior.color?

This would help since the built-in function 'Conditional formatting' is of
no help for my specific demands.

What i want is to let the user select a function called for instance
'FormatColor' from the insert function dialog box, and then choose an
refernence cell which contains the formats he wants to use.

Exampel

within VBA module:

Function FormatCell (Ref as Range)
Application.ActiveCell.Interior.Color = Ref.Interior.Color
End Function

The user then invokes the funktion via 'insert function - user defined
funtion - FormaCell'
- Picks the reference cell of chiose.

This does not work - I've tried... :o(
And by the way, Excel hangs!

(i've tried this with Excel XP)

Help, please

/Jonas Caspersson




 
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
User Defined function - Help makulski Excel Worksheet Functions 8 February 27th 08 09:44 PM
user defined function ub Excel Worksheet Functions 6 April 4th 07 09:42 PM
User Defined Function Barb Reinhardt Excel Worksheet Functions 3 March 28th 07 02:23 AM
user defined function driller Excel Worksheet Functions 1 November 18th 06 04:51 PM
User defined function linzhang426 New Users to Excel 4 October 10th 05 03:18 PM


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