VBA Compilation Error

I have very little experience with VBA, and the last time I used it many years ago. Here is my VBA:

Function MacIDGen(total, current)
If total - current = 0 Then
    current -1
Else
    current 1
End If
    Macro1 (current)
End Function

Sub Macro1(cur)
    Sheets("Donations").Cells(I2).Value = cur & "Test"
End Sub

This is its own module, no other code with it at all.

So, I have a cell calling MacIDGen (). It passes the MacID to two other cell values. An error occurs whenever it is executed, “Compilation error: expected sub, function or property” and underlines the signature of the function method.

I have no idea why they are kicking him here, I suppose, because I either missed an important step, or something about how you cannot have a function in this context or some other such problem.

, Excel, drupal. , ( ), .

+4
2

Compile Error, , = current -1 current 1

, , , UDF . , . . #Value , .

A Function , - . , UDF ( ), - .

, ,

Function MacIDGen(total, current)     
    If total - current = 0 Then
        current = -1
    Else
        current = 1
    End If

    MacIDGen = current & "Test"
End Function
+2

, UDF, , commandButton, . , :

Sub MacIDGen(total, current)
Hide result
0

All Articles