error <Object doesn't support this property or method> in UDF RRS feed

  • Question

  • hi all,

    i have an error in my excel spreadsheet. i call an UDF that call a macro. the macro works if i launch it directly but when the macro is called by my function and try to change a value for a range or a cell there is an error.

    here my vba code.

    please can tell how to make it works.

    Thank in advance.



    Public Function gethello() As String

    getAlaskaDatas = "hello"
    End Function

    Sub Hello()

    On Error GoTo funcfail

    Dim iCol As Integer
    Dim lRow As Long
    Dim sText As String
    iCol = 2
    lRow = 3
    sText = "Hello Excel"

    Worksheets(1).Range("A1:B3").Value = sText

    Exit Sub

      MsgBox Err.Description
    End Sub

    lundi 10 août 2009 10:11

Toutes les réponses

  • Are you trying to call your function from a formula in a cell?

    Because you can't. User defined functions are not allowed to modify other cells, even indirectly. They will not execute.

    lundi 7 novembre 2011 05:07