Results 1 to 2 of 2
  1. #1

    User input for a VBA function

    Hi All

    I need to write a user defined function in VBA that will accept an unknown number of inputs from the user. The inputs need to be either literal numbers, or cell ranges. The built in function SUM does exactly what I need.

    How do I do this?

    Also, any information on how to supply the help information that the Function Wizard shows the user would also be greatly appreciated.

    Thanks for your help

  2. #2
    Platinum Lounger
    Join Date
    Feb 2001
    Weert, Limburg, Netherlands
    Thanked 0 Times in 0 Posts

    Re: User input for a VBA function

    Maybe this gives some idea's:

    Option Explicit

    Function mysum(ByVal vData As Variant, Optional vExtradata)
    Dim vTemp As Variant
    Dim element As Variant
    On Error Resume Next
    vTemp = 0
    For Each element In vData
    vTemp = vTemp + element
    If Not IsMissing(vExtradata) Then
    For Each element In vExtradata
    vTemp = vTemp + element
    End If
    mysum = vTemp
    End Function
    Jan Karel Pieterse
    Microsoft Excel MVP, WMVP
    Professional Office Developers Association

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts