Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Can't Update Cells from a Function?

I have a function for which I'd like to update some cells
programmatically. For the purposes of simplicity, I've
boiled the problem down to:

Function CellUpdt(InR as Range, OutC as Range) As Integer
' Do some processing with InR
...

' Update some spreadsheet cells
Cells(OutCell.Row, OutCell.Column) = "Value1"

' Return
CellUpdt = 0
End Function

The function is driven from the spreadsheet itself, ie.,
=CellUpdt(M24:P50,R7:R10).

I can't seem to get this work. In the debugger, when I
reach the 1st assignment statement, the program just
ends - no errors, no messages.

Anybody know what's wrong?

Thanks, Tommy
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Can't Update Cells from a Function?

Hi Tommy
a function (UDF) can't do this. You are not able to change cells or
formats or other things. You can only return values

Frank

Tommy wrote:
I have a function for which I'd like to update some cells
programmatically. For the purposes of simplicity, I've
boiled the problem down to:

Function CellUpdt(InR as Range, OutC as Range) As Integer
' Do some processing with InR
...

' Update some spreadsheet cells
Cells(OutCell.Row, OutCell.Column) = "Value1"

' Return
CellUpdt = 0
End Function

The function is driven from the spreadsheet itself, ie.,
=CellUpdt(M24:P50,R7:R10).

I can't seem to get this work. In the debugger, when I
reach the 1st assignment statement, the program just
ends - no errors, no messages.

Anybody know what's wrong?

Thanks, Tommy



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Can't Update Cells from a Function?

Tommy,

The design is unsound - you can't do what you want to do. A worksheet
function can return a value to the calling cell, it can change other cells
as you are trying to do.

For this, you need to use the Worksheet_Change event code.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Tommy" wrote in message
...
I have a function for which I'd like to update some cells
programmatically. For the purposes of simplicity, I've
boiled the problem down to:

Function CellUpdt(InR as Range, OutC as Range) As Integer
' Do some processing with InR
...

' Update some spreadsheet cells
Cells(OutCell.Row, OutCell.Column) = "Value1"

' Return
CellUpdt = 0
End Function

The function is driven from the spreadsheet itself, ie.,
=CellUpdt(M24:P50,R7:R10).

I can't seem to get this work. In the debugger, when I
reach the 1st assignment statement, the program just
ends - no errors, no messages.

Anybody know what's wrong?

Thanks, Tommy



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Can't Update Cells from a Function?

Thanks to all. Looks like I'll have to change my design.

-----Original Message-----
I have a function for which I'd like to update some

cells
programmatically. For the purposes of simplicity, I've
boiled the problem down to:

Function CellUpdt(InR as Range, OutC as Range) As Integer
' Do some processing with InR
...

' Update some spreadsheet cells
Cells(OutCell.Row, OutCell.Column) = "Value1"

' Return
CellUpdt = 0
End Function

The function is driven from the spreadsheet itself, ie.,
=CellUpdt(M24:P50,R7:R10).

I can't seem to get this work. In the debugger, when I
reach the 1st assignment statement, the program just
ends - no errors, no messages.

Anybody know what's wrong?

Thanks, Tommy
.

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
Update tab function Ivone Excel Worksheet Functions 2 December 14th 09 11:00 PM
Don't Update Function RedFive Excel Discussion (Misc queries) 1 September 23rd 08 02:38 PM
Cells w/ user defined function do not auto update John Excel Worksheet Functions 2 September 14th 08 07:06 PM
Function Update Stevek Excel Worksheet Functions 3 December 14th 06 06:48 PM
How do I link a row of cells in wks 1 to update diff cells wks 2 Andy Excel Worksheet Functions 1 February 10th 06 04:27 PM


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