Consulting

Results 1 to 6 of 6

Thread: function variables show on sheet

  1. #1
    VBAX Newbie
    Joined
    Sep 2011
    Posts
    2
    Location

    function variables show on sheet

    I am new to VBA and I hope I can explain this properly. I wrote a function: isValidISBN and it will show up on the scroll menu if i select a cell and start typing isVa... in the same way that =sum, and =vlookup come up. I was wondering if there was a way to display the needed variables. For example =sumif(range,criteria,[sum_range]). I want the "range,criteria,[sum_range]" equivalents of my function to show. As of now it just says "isValidISBN("
    Is there a way to do this in VBA?

  2. #2
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    No. There are ways to give help for your function as if Fx was pressed.

  3. #3
    VBAX Newbie
    Joined
    Sep 2011
    Posts
    2
    Location
    Quote Originally Posted by Kenneth Hobs
    No. There are ways to give help for your function as if Fx was pressed.
    Thanks. How is that done?

  4. #4
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    There are some involved methods that lets you add more help than the more simple method of Applicaton.MacroOptions.

  5. #5
    VBAX Expert
    Joined
    Aug 2004
    Posts
    810
    Location
    you could try something like this, type your formula then hit (for example "=sum")
    1 - Control A
    2 - Control Shift A

    Take your pick

  6. #6
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    As JKwan said, you can use option 2. What you can not do is to add the popup as standard functions like =Sum().

    For the help by method 1, add it by Application.MacroOptions.

    e.g.
    [VBA]Sub AddDesc_DisRangeCountIf()
    Application.MacroOptions Macro:="DisRangeCountIf", _
    Description:="Used like built-in function,=CountIf" & vbCrLf _
    & "DisRange: Contiguous or Discontiguous range." _
    & vbCrLf & "sCriteria: A string for the criteria.", _
    Category:="Kens Functions"
    End Sub

    Function DisRangeCountIf(ByVal DisRange As Range, ByVal sCriteria As String)
    Dim dblCount As Double
    dblCount = 0
    For Each cell In DisRange.Cells
    dblCount = dblCount + WorksheetFunction.CountIf(cell, sCriteria)
    Next
    DisRangeCountIf = dblCount
    End Function
    [/VBA]

Posting Permissions

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