Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
1004 "Application-defined or object-defined error"
Guys,
The following code gives the 1004 "Application-defined or object-defined error" error when is inside a function: Function myFunction() As Integer myFunction = 0 On Error GoTo Error Worksheets(1).Range("B2").Value = 3.14159 Exit Function Error: MsgBox Err.Number & vbCrLf & Err.Description, vbExclamation, "Error in myFunction" myFunction = -1 End Function But the same code works inside a sub: Sub mySub() On Error GoTo Error Worksheets(1).Range("B2").Value = 3.14159 Exit Sub Error: MsgBox Err.Number & vbCrLf & Err.Description, vbExclamation, "Error in mySub" End Sub I can't figure out why and can't work around it. Does anyone have any ideias? Any help would be deeply appreciated. Thanks in advance! |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Macro Run-time Error 1004 Application Defined or Object Defined Error | Excel Programming | |||
What does "Application-defined or object-defined error" mean? | Excel Programming | |||
"Application-defined or object-defined error" while printing excel report | Excel Programming | |||
"Run Time Error 1004 Application Defined or Object Defined Error." | Excel Programming |