VBA Excel Macro

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • chanshaw
    New Member
    • Nov 2008
    • 67

    VBA Excel Macro

    I hope this is the right forum for this (if not let me know where i should have posted this) Alright I'm having a little trouble passing some arguments to a function and then having it return what I need it to.

    Code:
    Sub Startup()
        ProcessCollection(colAbvs, 4)
    End Sub
    
    Function ProcessCollection(incCollection As Collection, specifiedLength As Integer)
        For counter = 1 To incCollection.Count
        tempString = incCollection.Count
        stringLength = Len(tempString)
        If (stringLength > specifiedLength) Then
            MsgBox stringLength & " is greater than specified length"
        ElseIf (stringLength < specifiedLength) Then
            MsgBox stringLength & " is less than specified length"
        ElseIf (stringLength = specifiedLength) Then
            MsgBox "Equal"
    End Function
    It doesn't seem to like me passing it arguments this way can someone let me know what im doing wrong.
  • ChipR
    Recognized Expert Top Contributor
    • Jul 2008
    • 1289

    #2
    I haven't tried this with a Collection, but assuming that all works, line #7 would have to reference the variable counter instead of Count.

    Comment

    Working...