Rename to something other than C ... ie CVAL or some such.
Also note the following:
a) Integer type is whole numbers limited to range -32768 - 32767 ... use Long if you expect to exceed that or Double if you expect to require Decimal places.
(Integers in VBA are coerced under the hood to Longs anyway so there's no memory gain in using Integer)
b) VBA by default is Case Sensitive so be sure you're Select Case is using appropriate Case in criteria etc... if you want to be Case Insensitive either
i) coerce passed values to Upper Case (ie UCase(p1)) and set criteria to be Upper Case also
or
ii) use Option Compare Text at head of module to make the Module case insensitive.
c) Remove the
the above serves no real purpose given when initialised the variable j will default to 0... also it is in the wrong position - ie j will be 0 where Case is "C"... you would really put this above the Select Case line if it were needed (ie if default to be other than 0)
d) If you wish i to be Integer type then use:
Dim i As Integer, j As Integer
and not
given the above in VBA (unlike .NET) is akin to saying:
Dim i As Variant, j As Integer
Bookmarks