Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default [Newbie question] Returning an array from a function

Hi,

I only started a few days ago working with Excel add-ins. :)
I would like to make a function (that can be called from a cell!),
that will fill an array of values and return them on the sheet. To be
more clear, I would like to write in a cell(i.e. A1) =MyFunc(), and
when the function is called, in the cells A1-B4 I will have values
like:
0 11
1 11
2 21
3 31

I tried using the FP stucture, and I wrote something like this:
...
{" MyFunc", " K", " MyFunc", " ", " 1", " MyCat", " ", " ", " test
func"},
...

FP* __stdcall AVM_Schedule(void)
{
FP arr;
arr.rows = 4;
arr.columns = 2;
for(int i=0; i<4; i++)
for(int j=0; j<2; j++)
arr.array[i*4+j]=i*10+j;

return &arr
}

When I run this function, I get the first value in the array (in this
case 0) in the cell where I entered the function call.

Probably I'm trying a wrong approach. Could you please help me get on
the right track? Some sample code about this issue would be very nice.
Thanks!

Best regards,
Doru K
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 783
Default [Newbie question] Returning an array from a function

I don't understand your code, but try highlighting A1:B4 instead of just
A1, and using Ctrl+Shift+Enter instead of just Enter.

Alan Beban

dorutzu wrote:
Hi,

I only started a few days ago working with Excel add-ins. :)
I would like to make a function (that can be called from a cell!),
that will fill an array of values and return them on the sheet. To be
more clear, I would like to write in a cell(i.e. A1) =MyFunc(), and
when the function is called, in the cells A1-B4 I will have values
like:
0 11
1 11
2 21
3 31

I tried using the FP stucture, and I wrote something like this:
...
{" MyFunc", " K", " MyFunc", " ", " 1", " MyCat", " ", " ", " test
func"},
...

FP* __stdcall AVM_Schedule(void)
{
FP arr;
arr.rows = 4;
arr.columns = 2;
for(int i=0; i<4; i++)
for(int j=0; j<2; j++)
arr.array[i*4+j]=i*10+j;

return &arr
}

When I run this function, I get the first value in the array (in this
case 0) in the cell where I entered the function call.

Probably I'm trying a wrong approach. Could you please help me get on
the right track? Some sample code about this issue would be very nice.
Thanks!

Best regards,
Doru K

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default [Newbie question] Returning an array from a function



WOW! That works! Thanks! I'm amazed. Great! :)

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 783
Default [Newbie question] Returning an array from a function

Doru K wrote:

WOW! That works! Thanks! I'm amazed. Great! :)

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Thanks for the feedback. It's called "array entering".

Alan Beban
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default [Newbie question] Returning an array from a function

On the same topic, is there a way to return an array of strings, instead
of doubles? I would like to return some strings, but the array field of
the PF structure allows me only to use double values.
Thanks!
Doru K

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
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
Newbie Question, NOW() function justin4480 Excel Worksheet Functions 3 May 29th 06 10:31 PM
newbie question on multi-dimensional array sammus New Users to Excel 2 April 3rd 06 03:11 AM
Newbie Question: Returning the value from a cell on another sheet SmilingPolitely[_2_] Excel Programming 4 July 14th 04 01:23 PM
function returning array dreamer[_18_] Excel Programming 1 June 8th 04 10:43 AM
returning an array from a custom function Ron Davis Excel Programming 2 September 15th 03 11:02 AM


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