Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default write to range object using vb.net

Hi,

hopefully this is the right group for posting my question.

I'm writing an automation addin for excel using vb.net. One of my
function should be able to overwrite the cell values of a range object
passed as parameter to the function. Here is a small sample of the
function header:

Public Function WriteData(ByRef ResultCells As Range) As Double

I tried the following:
ResultCells.Value2(1, 1) = 42
ResultCells.Value(1, 1) = 42
ResultCells.Cells(1, 1).FormularR1C1 = 42

None of these calls work.

Does anybody know how to overwrite values of a range object? Are there
any other ways to return multiple valus from a user-defined function?

Regards,
Sascha
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default write to range object using vb.net

Sascha,

I'm not sure of VB.NET, but in VBA functions cannot be used to write data to ranges - the code that
does it is simply ignored. Try passing the range to a public Sub instead....

HTH,
Bernie
MS Excel MVP


wrote in message
...
Hi,

hopefully this is the right group for posting my question.

I'm writing an automation addin for excel using vb.net. One of my
function should be able to overwrite the cell values of a range object
passed as parameter to the function. Here is a small sample of the
function header:

Public Function WriteData(ByRef ResultCells As Range) As Double

I tried the following:
ResultCells.Value2(1, 1) = 42
ResultCells.Value(1, 1) = 42
ResultCells.Cells(1, 1).FormularR1C1 = 42

None of these calls work.

Does anybody know how to overwrite values of a range object? Are there
any other ways to return multiple valus from a user-defined function?

Regards,
Sascha



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default write to range object using vb.net

Hello,

I'm not sure of VB.NET, but in VBA functions cannot be used to write data to ranges - the code that
does it is simply ignored. *Try passing the range to a public Sub instead....

it seems to be the same in vb.net. The code compiles, throws no error,
but doesn't work either. The workaround for me is to return a
Double(,)-Array. That way I can return a matrix, but the user can not
control the order and placement of the result columns. Not nice, but
it works...

Regards,

Sascha
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
How to write macro to move object via if function Ged Excel Discussion (Misc queries) 4 February 20th 06 12:34 AM
returning pivottable object from a range object Grant Excel Programming 2 September 27th 04 02:22 AM
Range object to Array object conversion Myrna Larson[_2_] Excel Programming 1 August 1st 03 02:27 AM
Range object to Array object conversion Alan Beban[_3_] Excel Programming 0 August 1st 03 01:24 AM
Range object to Array object conversion Tom Ogilvy Excel Programming 0 August 1st 03 12:16 AM


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