L
Lamy
Hi,
I try to write into a cell in Excel 2007 worksheet. This works fine
from a procedure, but it raises an runtime error 1004: application or
object defined error called in a function.
See my code below. The sub runs fine, the function crashes. Whats
wrong?
Thanks for any hint.
Lamy
Option Explicit
Sub ttt()
ThisWorkbook.Sheets(1).Cells(21, 5).Value = 7
End Sub
Function fff() As Double
On Error GoTo Excelisbuggy
ThisWorkbook.Sheets(1).Cells(22, 5).Value = 9 'raising runtime
error 1004 here
fff = 5.6
Exit Function
Excelisbuggy:
Debug.Print Str(Err.Number) + ":" + Err.Description
End Function
I try to write into a cell in Excel 2007 worksheet. This works fine
from a procedure, but it raises an runtime error 1004: application or
object defined error called in a function.
See my code below. The sub runs fine, the function crashes. Whats
wrong?
Thanks for any hint.
Lamy
Option Explicit
Sub ttt()
ThisWorkbook.Sheets(1).Cells(21, 5).Value = 7
End Sub
Function fff() As Double
On Error GoTo Excelisbuggy
ThisWorkbook.Sheets(1).Cells(22, 5).Value = 9 'raising runtime
error 1004 here
fff = 5.6
Exit Function
Excelisbuggy:
Debug.Print Str(Err.Number) + ":" + Err.Description
End Function