Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Capabilities of a User-Defined Function

I know this is a strange question, but do UDFs have the ability to
change the spreadsheet's properties? For example, I have a function
which computes a value, but I needed it to merge the cell with the one
below if that value met certain conditions. It doesn't seem to want to
do the merge, but it seems to me that VBA instructions in the UDF are
just that; instructions. It shouldn't matter whether they affect cell
properties or not.

Am I correct, or have the programmers of Excel given it enough
sophistication to know that a UDF is purely for producing a value?

Thanks for any input...

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Capabilities of a User-Defined Function

Hi Dennis,

A UDF returns a value to the calling cell; it cannot alter its environment.


---
Regards,
Norman



"Dennis Snelgrove" wrote in message
ups.com...
I know this is a strange question, but do UDFs have the ability to
change the spreadsheet's properties? For example, I have a function
which computes a value, but I needed it to merge the cell with the one
below if that value met certain conditions. It doesn't seem to want to
do the merge, but it seems to me that VBA instructions in the UDF are
just that; instructions. It shouldn't matter whether they affect cell
properties or not.

Am I correct, or have the programmers of Excel given it enough
sophistication to know that a UDF is purely for producing a value?

Thanks for any input...



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 535
Default Capabilities of a User-Defined Function

Hi Dennis,

I know this is a strange question, but do UDFs have the ability to
change the spreadsheet's properties?


No they have not. They do what they are designed for: return results.

BTW: I advise against merging cells, too much trouble with sorting and
copying.

Regards,

Jan Karel Pieterse
Excel MVP
http://www.jkp-ads.com

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Capabilities of a User-Defined Function

It turns out that functions can do some strange things.

John Walkenbach has a few things documented:
http://j-walk.com/ss/excel/odd/odd06.htm

They can insert comments into other cells.

And they can merge cells (even other cells that don't hold that formula).

You can try something like:

Option Explicit
Function testme01()

Dim a As Long
Dim b As Long
a = 5
b = 10

If a < b Then
Application.Caller.Offset(3, 3).Resize(4, 4).Merge
End If
End Function

in your function.

But I'm not sure if this is a bug in excel (that may be fixed in newer
versions). You may want to do things like this with both eyes wide open.

(And I agree with Jan Karel--merged cells are a pain to work with. I try to
avoid them at all costs.)



Dennis Snelgrove wrote:

I know this is a strange question, but do UDFs have the ability to
change the spreadsheet's properties? For example, I have a function
which computes a value, but I needed it to merge the cell with the one
below if that value met certain conditions. It doesn't seem to want to
do the merge, but it seems to me that VBA instructions in the UDF are
just that; instructions. It shouldn't matter whether they affect cell
properties or not.

Am I correct, or have the programmers of Excel given it enough
sophistication to know that a UDF is purely for producing a value?

Thanks for any input...


--

Dave Peterson
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
User Defined FUNCTION EAK Excel Discussion (Misc queries) 5 July 17th 08 07:07 PM
User defined function linzhang426 New Users to Excel 4 October 10th 05 03:18 PM
User-defined data type; Error: Only User-defined types... tiger_PRM Excel Programming 1 July 18th 04 03:32 PM
USer Defined Function Excel Dummy[_2_] Excel Programming 2 November 5th 03 11:33 AM
User-Defined Function pre-empting Built-in Function? How to undo???? MarWun Excel Programming 1 August 6th 03 09:31 PM


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