Connecting Tech Pros Worldwide Forums | Help | Site Map

VBA Excel Macro

Member
 
Join Date: Nov 2008
Posts: 61
#1: Jun 18 '09
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.

Expand|Select|Wrap|Line Numbers
  1. Sub Startup()
  2.     ProcessCollection(colAbvs, 4)
  3. End Sub
  4.  
  5. Function ProcessCollection(incCollection As Collection, specifiedLength As Integer)
  6.     For counter = 1 To incCollection.Count
  7.     tempString = incCollection.Count
  8.     stringLength = Len(tempString)
  9.     If (stringLength > specifiedLength) Then
  10.         MsgBox stringLength & " is greater than specified length"
  11.     ElseIf (stringLength < specifiedLength) Then
  12.         MsgBox stringLength & " is less than specified length"
  13.     ElseIf (stringLength = specifiedLength) Then
  14.         MsgBox "Equal"
  15. End Function
  16.  
It doesn't seem to like me passing it arguments this way can someone let me know what im doing wrong.

Expert
 
Join Date: Jul 2008
Location: Maryland
Posts: 1,253
#2: Jun 18 '09

re: VBA Excel Macro


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.
Reply