ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to Modify Worksheet Range when called by a UDF (https://www.excelbanter.com/excel-programming/409027-how-modify-worksheet-range-when-called-udf.html)

Michael Franz

How to Modify Worksheet Range when called by a UDF
 
Hi,

I have been spinning my wheels trying to figure out how to solve my problem.
I am not sure if using a UDF is the correct solution. I have read that UDF
cannot modify worksheets if they are called in a certain way, but can if they
are called another way. I have read about Excel Addins, COM Addins and UDFs
and feel confused on which of these will provide the solution.

What I want to do is provide a funtion that a user can use that will take in
parameters, and then return the result by modifing a range of cells. One of
the parameters passed in will be the starting cell for the resulting range.

I need to write most of this code (if not all) in C# (VB.NET). We are
trying to limit the amount of VBA code that we need in our solution.

Being pointed in the right direction is greatly appreciated.

Michael


Jim Thomlinson

How to Modify Worksheet Range when called by a UDF
 
The question is how is the function called.
If the function is called by adding a formula to a cell then it can only
modify the value of the cell that it is in. Similar to any function in XL
such as sum or average it's scope is limited to the cell that it is in.
If however the function is called using a command button or event then a
function has free reign to do whatever it wants to any number of cells in any
number of sheets.
--
HTH...

Jim Thomlinson


"Michael Franz" wrote:

Hi,

I have been spinning my wheels trying to figure out how to solve my problem.
I am not sure if using a UDF is the correct solution. I have read that UDF
cannot modify worksheets if they are called in a certain way, but can if they
are called another way. I have read about Excel Addins, COM Addins and UDFs
and feel confused on which of these will provide the solution.

What I want to do is provide a funtion that a user can use that will take in
parameters, and then return the result by modifing a range of cells. One of
the parameters passed in will be the starting cell for the resulting range.

I need to write most of this code (if not all) in C# (VB.NET). We are
trying to limit the amount of VBA code that we need in our solution.

Being pointed in the right direction is greatly appreciated.

Michael


Michael Franz

How to Modify Worksheet Range when called by a UDF
 
Jim,

Does wrapping the UDF in VBA also give it the ability to do whatever it wants?

Would an RTD server also be able to do whatever it wants?

Thanks

Michael
"Jim Thomlinson" wrote:

The question is how is the function called.
If the function is called by adding a formula to a cell then it can only
modify the value of the cell that it is in. Similar to any function in XL
such as sum or average it's scope is limited to the cell that it is in.
If however the function is called using a command button or event then a
function has free reign to do whatever it wants to any number of cells in any
number of sheets.
--
HTH...

Jim Thomlinson




All times are GMT +1. The time now is 10:22 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com