ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Cannot change Cell value (https://www.excelbanter.com/excel-programming/392967-cannot-change-cell-value.html)

[email protected]

Cannot change Cell value
 
Hi, this gotta be something very simple that I'm missing. The
following function is inside a module and it fails on Worksheet ...
statement. The function returns #value

Function ddddd(X As Double) As Double

Worksheets("Sheet1").Range("A1").Value = 123

ddddd = X + 1

End Function

Also Worksheets("Sheet1").Cells(1,1).Value = 123 fails in the same
manner

Thank you!


Jim Rech

Cannot change Cell value
 
Remove the

Worksheets("Sheet1").Range("A1").Value = 123

A UDF cannot do anything other than return a value to the cell it's in.

--
Jim
wrote in message
ps.com...
| Hi, this gotta be something very simple that I'm missing. The
| following function is inside a module and it fails on Worksheet ...
| statement. The function returns #value
|
| Function ddddd(X As Double) As Double
|
| Worksheets("Sheet1").Range("A1").Value = 123
|
| ddddd = X + 1
|
| End Function
|
| Also Worksheets("Sheet1").Cells(1,1).Value = 123 fails in the same
| manner
|
| Thank you!
|



Wigi

Cannot change Cell value
 
"Jim Rech" wrote:

A UDF cannot do anything other than return a value to the cell it's in.

--
Jim


True. Also, no formatting can be done. What I found a bit strange when I saw
it, is that a UDF can produce a MsgBox.

--
Wigi
http://www.wimgielis.be = Excel/VBA, soccer and music




Jim Rech

Cannot change Cell value
 
a UDF can produce a MsgBox

True enough. It just cannot 'do' anything to a workbook itself.

--
Jim
"Wigi" wrote in message
...
| "Jim Rech" wrote:
|
| A UDF cannot do anything other than return a value to the cell it's in.
|
| --
| Jim
|
| True. Also, no formatting can be done. What I found a bit strange when I
saw
| it, is that a UDF can produce a MsgBox.
|
| --
| Wigi
| http://www.wimgielis.be = Excel/VBA, soccer and music
|
|
|




All times are GMT +1. The time now is 05:47 PM.

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