Array with a Loop!

bgcogen

Registered User.
Local time
Today, 07:57
Joined
Apr 19, 2002
Messages
61
Hi!
Kinda of an Excel type VBA question, sorry!!

Basically I have a string array declared as:

Dim MyArray(5) As String
MyArray(0) = "BG1"
MyArray(1) = "BG2"
MyArray(2) = "BG3"
MyArray(3) = "BG4"
MyArray(4) = "BG5"

Anywho, in the code I need to loop through a particular section of code with all of the elements in the array, i.e:

x = 0

Do Until x = 5
Selection = MyArray(x)

If Selection = "BG1" Then
...... Same code
..... Same code

If Selection = "BG2" Then
..... Same code
..... Same code

End Select

x = x + 1
Loop

But when it gets to the I get an "object doesn't support this property or method" error.

What can I do? Any thoughts???

Thanks,
D
 
Could you tell us what you are trying to do. Is this code going to run in an Excel workbook?
 
Either get rid of the End Select and go

If Selection = "BG1" Then
stuff here
else If Selection = "BG2" Then
more stuff
else if
etc etc
end if

or go

Select Case MyArray(x)

case "BG1"
stuff here
case "BG2"
moe stuff
end select
 

Users who are viewing this thread

Back
Top Bottom