Cannot change Cell value

  • Thread starter Thread starter brains4math
  • Start date Start date
B

brains4math

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!
 
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
| 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 said:
A UDF cannot do anything other than return a value to the cell it's in.

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.
 
a UDF can produce a MsgBox

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

--
Jim
| "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
|
|
|
 
Back
Top