PC Review


Reply
Thread Tools Rate Thread

Automation add-in - UDF to multi cells...

 
 
dale purdon
Guest
Posts: n/a
 
      8th May 2008
Hi all,

I have been doing some reading on this forum and could not find exactly
what i was looking for so i decided to post. I have an automation add-in
written in C#. I need a UDF function to populate multiple cells with
data. (like a table of data, and the cell containing the UDF function
would be the top left corner of the 'rendered' table).

Is this possible?

I have read that a UDF function can only return and populate a single
cell. Well there must be some way to do it as I have seen other add-ins
do this, and im trying to replicate the behaviour.

Thanks!

Dale

*** Sent via Developersdex http://www.developersdex.com ***
 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      8th May 2008
A UDF can only return something to the range that holds that UDF.

But if you select the range (say A1:B4) and array enter your formula (using
ctrl-shift-enter), then all 8 of these cells could be populated by that single
array formula in multiple cells.

I don't speak the C#, but in VBA, I'd use this kind of thing:

Option Explicit
Function myFunct() As Variant
Dim myArr(1 To 4, 1 To 2) As Variant
Dim rCtr As Long
Dim cCtr As Long

For rCtr = LBound(myArr, 1) To UBound(myArr, 1)
For cCtr = LBound(myArr, 2) To UBound(myArr, 2)
myArr(rCtr, cCtr) = "R" & rCtr & "--" & "C" & cCtr
Next cCtr
Next rCtr

myFunct = myArr

End Function




dale purdon wrote:
>
> Hi all,
>
> I have been doing some reading on this forum and could not find exactly
> what i was looking for so i decided to post. I have an automation add-in
> written in C#. I need a UDF function to populate multiple cells with
> data. (like a table of data, and the cell containing the UDF function
> would be the top left corner of the 'rendered' table).
>
> Is this possible?
>
> I have read that a UDF function can only return and populate a single
> cell. Well there must be some way to do it as I have seen other add-ins
> do this, and im trying to replicate the behaviour.
>
> Thanks!
>
> Dale
>
> *** Sent via Developersdex http://www.developersdex.com ***


--

Dave Peterson
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Multi-step query/automation problem Tony in Michigan Microsoft Access Queries 2 11th Jun 2009 07:55 PM
Automation of Keystrokes in Populated Cells. Aldini Microsoft Excel Programming 2 16th Oct 2008 06:41 PM
[Automation] Why do my cells with formula appear as text? =?Utf-8?B?U3R1YXJ0?= Microsoft Excel Programming 1 15th Nov 2007 09:02 AM
Pulling values out of cells using automation =?Utf-8?B?c2VhYmlyZA==?= Microsoft Excel Programming 0 4th Aug 2006 12:49 PM
Numberformat for Cells using Automation =?Utf-8?B?YmF2amVhbg==?= Microsoft Excel Programming 3 8th Feb 2005 12:07 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:42 PM.