Results 1 to 10 of 10

User-defined function that mimics the behavior of case select

Threaded View

  1. #1
    Registered User
    Join Date
    09-28-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    53

    User-defined function that mimics the behavior of case select

    I'm looking to create my own case select function that behaves basically like the =IF built-in function but can be used without nesting. It's hard to come by detailed tutorials on function building, especially for what I'm trying to do since it's more complicated than calculating the area of a rectangle, for example.

    The code below is what I have so far. I know it's not correct, but I don't know how to how to put it together. I'd like to have a larger set of optional arguments too, maybe 5 or 6.

    Public Function CaseSelect(Case1 As Variant, Do1 As Variant, Optional Case2 As Variant, Optional Do2 As Variant)
    
        Dim MyCase As Variant
        
        Select Case MyCase
            Case Case1
                Do1
            Case Case2
                Do2
            Case Else
        End Select
    
    End Function
    Last edited by Telperion; 03-20-2013 at 10:39 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1