'Converting Sub to Function

This sub macro fills from the current active cell to the right, Numvendors amount of times with the input function.

Sub FunctionFill()

    Dim myFunction As String: myFunction = "=SUM(A1:A5)"
    Dim Numvendors As Integer: Numvendors = 4
    Cells(Application.ActiveCell.Row, Application.ActiveCell.Column).Resize(, Numvendors).Formula = myFunction
    
End Sub

How do I change this sub into a function that takes Numvendors and myFunction as inputs and outputs the range.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source