Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default function to modify other cells

I am trying to write a function to modify a group of cells. As an example in
cell C1 I insert "=myfunction(1)" and in cells A1, B1, D1, E1 I want the
values of 3, 5, 7, and 11 placed.

At the assignment I get a 1004 error number returned.

My thought is that functions are not allowed to modify cells directly. Is
this correct?

--
John Rater
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default function to modify other cells

A function called from a worksheet cell cannot change the value of any
other cell. It can only return a value to the cell(s) from which it
was called. The reason for this limitation is that Excel must keep
track of which cells are dependent on which other cells so it can
calculate in the proper order. Excel can't determine what VBA code
might do, so it disallows code from changing other cells.

Cordially,
Chip Pearson
Microsoft MVP
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)


On Wed, 26 Nov 2008 08:18:13 -0800, rat59man
wrote:

I am trying to write a function to modify a group of cells. As an example in
cell C1 I insert "=myfunction(1)" and in cells A1, B1, D1, E1 I want the
values of 3, 5, 7, and 11 placed.

At the assignment I get a 1004 error number returned.

My thought is that functions are not allowed to modify cells directly. Is
this correct?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default function to modify other cells

Just a quick note. Even if you could write a function that modified other
cell it would be a really bad idea. Lets assume that we could. In Cell A1 you
have the value 3. Did someone input that value there? Did a function put it
there? If so which function? If 2 functions can modify the same cell which
one put a value there last? Any spreadsheet with those types of functions
would be impossible to debug.
--
HTH...

Jim Thomlinson


"Chip Pearson" wrote:

A function called from a worksheet cell cannot change the value of any
other cell. It can only return a value to the cell(s) from which it
was called. The reason for this limitation is that Excel must keep
track of which cells are dependent on which other cells so it can
calculate in the proper order. Excel can't determine what VBA code
might do, so it disallows code from changing other cells.

Cordially,
Chip Pearson
Microsoft MVP
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)


On Wed, 26 Nov 2008 08:18:13 -0800, rat59man
wrote:

I am trying to write a function to modify a group of cells. As an example in
cell C1 I insert "=myfunction(1)" and in cells A1, B1, D1, E1 I want the
values of 3, 5, 7, and 11 placed.

At the assignment I get a 1004 error number returned.

My thought is that functions are not allowed to modify cells directly. Is
this correct?


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 120
Default function to modify other cells

Another quick note. Your function can, of course, "modify" (better to say
"put new values" to) a contigues range of cells. This is a way called "array
function" €“ find out the Help for it. In your case you would have to use your
wit with it, i.e. to place the argument at the end €“ to E1 cell instead of
C1, or to create a pair of functions - for the left and right ranges
alongside the argument cell. The best way, with the same function algorithm €“
as I take it from your example - is to propagate "one cell" function by
copying. When even this is out of your intentions, the only resting method is
creating a subroutine. By means of it you can do almost everything; you must
resign yourself only to the instant response to the argument change that the
function provides.

Regards
--
Petr Bezucha


"rat59man" wrote:

I am trying to write a function to modify a group of cells. As an example in
cell C1 I insert "=myfunction(1)" and in cells A1, B1, D1, E1 I want the
values of 3, 5, 7, and 11 placed.

At the assignment I get a 1004 error number returned.

My thought is that functions are not allowed to modify cells directly. Is
this correct?

--
John Rater

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 modify a range in a function? hdlee Excel Programming 0 February 28th 08 03:45 AM
Modify function for another workbook kirkm[_7_] Excel Programming 2 December 21st 07 10:34 AM
Unable to modify cells in a VBA function Sergio Aguayo Excel Programming 4 March 12th 07 05:52 PM
How a function can modify a value from some cells ? Cristian Excel Programming 5 January 3rd 06 08:10 PM
to modify cells from a function Pierre Laporte Excel Programming 1 July 10th 03 02:11 PM


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