Re: Error 1004: Application Defined or object defined error
- From: "Chip Pearson" <chip@xxxxxxxxxxxx>
- Date: Mon, 12 Jun 2006 05:44:14 -0500
First of all, you should have an 'Exit Function' immediately
before your Errfunction label. But more importantly, if you are
trying to call this function from a work*** cell, it won't work
because you are attempting the change the value of a cell. A
function that is called from a work*** cell may only return a
value to the calling cell. It may not change any part of the
Excel environment, and that includes changing the value of a
cell.
Try
Public Function returndate(inidate As Date) As Date
Dim calcdate As Double
calcdate = CDbl(inidate + 5)
On Error GoTo Errfunction
returndate = calcdate
Exit Function
Errfunction:
MsgBox Err.Description
MsgBox Err.Number
End Function
--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
"Panagiotis Marantos"
<PanagiotisMarantos@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:175C4939-538D-40A7-BE7F-4C551162FFDB@xxxxxxxxxxxxxxxx
i am trying to create a simple code (before i make it more
complicated) but i
fall on the first hurdle.
what is wrong with this?
Public Function returndate(inidate As Date) As Date
Dim calcdate As Double
calcdate = CDbl(inidate + 5)
On Error GoTo Errfunction
Application.Worksheets("Dates Lookup").Range("D6").Value =
calcdate
Errfunction:
MsgBox Err.Description
MsgBox Err.Number
End Function
.
- Prev by Date: Re: Hide whole row when cel C3 is 0 (zero)
- Next by Date: Re: Command Button on work***
- Previous by thread: Re: Select.Range
- Next by thread: Re: Error 1004: Application Defined or object defined error
- Index(es):