Closed Thread
Results 1 to 7 of 7

Loading Custom Data Type ?

Hybrid View

  1. #1
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    The UDF loadCmdVariable might help you. I changed the properties of the data type, (END scares me as a variable name), but the idea is the same.
    Type cmd
        begin As Long
        halt As Long
    End Type
    
    Function loadCmdVariable(ParamArray inputValues() As Variant) As cmd
      Select Case TypeName(inputValues(0))
          Case "Range"
              With inputValues(0)
                  loadCmdVariable.begin = .Range("a1").Value
                  loadCmdVariable.halt = IIf(.Rows.Count = 1, .Range("b1").Value, Range("a2").Value)
              End With
          Case "Byte", "Integer", "Long", "Double", "Single", "Variant", "Boolean"
              loadCmdVariable.begin = CLng(inputValues(0))
              loadCmdVariable.halt = CLng(inputValues(1))
          Case "String"
              loadCmdVariable.begin = Val(inputValues(0))
              loadCmdVariable.halt = Val(inputValues(1))
      End Select
      End Function
    
    Sub Test()
      Dim xType(1 To 3) As cmd
      Dim i As Long
    
      xType(1) = loadCmdVariable(Range("a1:b1"))
      xType(2) = loadCmdVariable(Range("a1:a2"))
      xType(3) = loadCmdVariable(1, 2)
      For i = 1 To 3
          MsgBox xType(i).begin & ":" & xType(i).halt
      Next i
      End Sub
    Last edited by mikerickson; 10-22-2007 at 09:09 PM.

  2. #2
    Registered User
    Join Date
    02-09-2005
    Posts
    63
    Mike - Exactly what I had in mind.

    THANKS

Closed Thread

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