Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default How a function can modify a value from some cells ?

I have a module with a function where I receive a range of cells. Every time
I try to modify the value of this cells I receive an error "out of context".
There are some way to do it ?

Best regards

Cristian
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 573
Default How a function can modify a value from some cells ?


Cristian wrote:
I have a module with a function where I receive a range of cells. Every time
I try to modify the value of this cells I receive an error "out of context".
There are some way to do it ?

Best regards

Cristian


You need to post the code here so one of the experts (not me) can see
exactly what the problem is.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 486
Default How a function can modify a value from some cells ?

Post your code... Also note that A UDF called from a worksheet can not modify
any cell other than the one it is called from... Called from code it can
change whatever it wants, but not if called from a sheet.
--
HTH...

Jim Thomlinson


"Cristian" wrote:

I have a module with a function where I receive a range of cells. Every time
I try to modify the value of this cells I receive an error "out of context".
There are some way to do it ?

Best regards

Cristian

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default How a function can modify a value from some cells ?

The code:

Function Teste(Cells As Object)

For Each cell In Cells
cell.Value = 11
Next

end function

"Jim Thomlinson" wrote:

Post your code... Also note that A UDF called from a worksheet can not modify
any cell other than the one it is called from... Called from code it can
change whatever it wants, but not if called from a sheet.
--
HTH...

Jim Thomlinson


"Cristian" wrote:

I have a module with a function where I receive a range of cells. Every time
I try to modify the value of this cells I receive an error "out of context".
There are some way to do it ?

Best regards

Cristian

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 486
Default How a function can modify a value from some cells ?

Cells is a reserved word. Try changing it it something like rngCells or
rCells...
--
HTH...

Jim Thomlinson


"Cristian" wrote:

The code:

Function Teste(Cells As Object)

For Each cell In Cells
cell.Value = 11
Next

end function

"Jim Thomlinson" wrote:

Post your code... Also note that A UDF called from a worksheet can not modify
any cell other than the one it is called from... Called from code it can
change whatever it wants, but not if called from a sheet.
--
HTH...

Jim Thomlinson


"Cristian" wrote:

I have a module with a function where I receive a range of cells. Every time
I try to modify the value of this cells I receive an error "out of context".
There are some way to do it ?

Best regards

Cristian



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default How a function can modify a value from some cells ?

Cristian,

Function Teste()
Teste = 11
End Function

Enter

=Teste()

into every cell in your range Cells.

OR: run the macro test()

Sub test()
Teste Range("A1:A10")
End Sub

Function Teste(myCells As Object)
For Each mycell In myCells
mycell.Value = 11
Next
End Function


HTH,
Bernie
MS Excel MVP


"Cristian" wrote in message
...
The code:

Function Teste(Cells As Object)

For Each cell In Cells
cell.Value = 11
Next

end function

"Jim Thomlinson" wrote:

Post your code... Also note that A UDF called from a worksheet can not modify
any cell other than the one it is called from... Called from code it can
change whatever it wants, but not if called from a sheet.
--
HTH...

Jim Thomlinson


"Cristian" wrote:

I have a module with a function where I receive a range of cells. Every time
I try to modify the value of this cells I receive an error "out of context".
There are some way to do it ?

Best regards

Cristian



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
Modify search function Dinesh Excel Worksheet Functions 3 March 18th 09 02:26 AM
How do I modify the autofit function in Excel? NadineWoj Excel Discussion (Misc queries) 2 February 22nd 06 10:25 PM
Can I modify a Hyperlink with a function? barrfly Excel Discussion (Misc queries) 7 June 2nd 05 12:03 AM
Modify cell from function Jason Callas Excel Programming 3 November 6th 03 05:08 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 06:13 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"