![]() |
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 |
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. |
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 |
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 |
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 |
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 |
All times are GMT +1. The time now is 04:21 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com