Thread: Array Check
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Jim Thomlinson[_3_] Jim Thomlinson[_3_] is offline
external usenet poster
 
Posts: 983
Default Array Check

Why is loadcases a variant? I ask because I think that the varaible type is
important here. Mid returns a string but your array is going to be full of
variants. This could be the source of your problem. Make sure that you are
comparing strings to strings or integers to integers... Based on your variant
declaration I would guess string to string but hard to tell from here...

HTH

"NacellesEng" wrote:

I have a lot of code, but the critical portion of it is an array check:

Dim loadcases() As Variant
loadcases = Array(1010!, 1020!.....etc)
Do Until Mid(ActiveCell.Value, 3, 4) = loadcases(i)
If ActiveCell.Value = "END" Then Exit Do
ActiveCell.Offset(1, 0).Select
Loop

I manually assign values to my array as show of 4 digit numbers and
then check a cell for the matching value. The cells actual value looks
something like this:
LC10101000000000

Why is is that can not find the match? I have checked both my MID
statement with a MsgBox to make sure it was pulling the 1010 and I
checked the loadcase(i) to make sure that also had 1010. But I never
finds the match. Any ideas? Thanks!