Every cell modifying line in the code below "throws" a 1004 error.
The following Function is called through a cell, this way: =bonjour()
Here is the code:
Public Function bonjour() As Integer
On Error GoTo Handler
Range("B2").Value = 41
Cells(2, 2) = 42
ThisWorkbook.Sheets("Feuil1").Range("B2").Value = 43
ThisWorkbook.Sheets("Feuil1").Cells(2, 2) = 44
Handler:
If Err.Number <> 0 Then
Debug.Print ("Error n° " & Err.Number & " - " & Err.Description)
Err.Clear
Resume Next
End If
bonjour = 45
End Function