David Tarum
David Tarum

Reputation: 55

vba := expected for a sub

I have a procedure :

Sub FormulaToNumber(sheetName As String, sheetRange As String)
Dim sh As Worksheet, Cell As Range, Plage As Range
Set sh = Worksheets(sheetName)

    sh.Select

    With sh

    Set Plage = .Range(sheetRange)

    For Each Cell In Plage
        Cell.Value = Format(Cell.Value, "Fixed")
    Next

    End With
    Application.CutCopyMode = False

End Sub

And I am trying to call my procedure like that :

FormulaToNumber("temps_ress", "D3:O95")

But Excel can't let me call my procedure, a messagebox appear with this text : "Error := expected" I think it wants a assination like : FormulaToNumber("temps_ress", "D3:O95") = variable, but why ?!

Upvotes: 1

Views: 639

Answers (2)

Paresh J
Paresh J

Reputation: 2419

You can simply use either of two option:

Call FormulaToNumber("temps_ress", "D3:O95")

OR

FormulaToNumber "temps_ress", "D3:O95"

Upvotes: 1

Mathieu Guindon
Mathieu Guindon

Reputation: 71187

The := operator is used for calling a function/procedure with named arguments... but I don't see anywhere where you're trying to do that. However...

And I am trying to call my procedure like that :

FormulaToNumber("temps_ress", "D3:O95")

Drop the parentheses:

FormulaToNumber "temps_ress", "D3:O95"

Upvotes: 1

Related Questions