Array trouble

A

Arturo

*********************
Dim HeadingsToSync As Variant

HeadingsToSync = Array("1", "2", "3", "ABC", "ABC %Total", "123ABC / 321CBA")

For y = LBound(HeadingsToSync) To UBound(HeadingsToSync)
MsgBox y
Next y
**********************

Why the duce doesn’t y display anything other than 0?

Sincerely,
Arturo
 
B

Bob Phillips

It is showing 0,1,2,3,4,5 for me one at a time.

Do you really want to show the array index?

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
D

Dave Peterson

This:

Option Explicit
Sub testme()
Dim HeadingsToSync As Variant
Dim y As Variant

HeadingsToSync _
= Array("1", "2", "3", "ABC", "ABC %Total", "123ABC / 321CBA")

For y = LBound(HeadingsToSync) To UBound(HeadingsToSync)
MsgBox y
Next y

End Sub

showed:
0, 1, 2, 3, 4, 5
for me.

And did you really mean to show the index?

Maybe:

Option Explicit
Sub testme()
Dim HeadingsToSync As Variant
Dim iCtr As Long

HeadingsToSync _
= Array("1", "2", "3", "ABC", "ABC %Total", "123ABC / 321CBA")

For iCtr = LBound(HeadingsToSync) To UBound(HeadingsToSync)
MsgBox HeadingsToSync(iCtr)
Next iCtr

End Sub

And I got to see the headers.

This also showed the headers:

Option Explicit
Sub testme()
Dim HeadingsToSync As Variant
Dim myElement As Variant

HeadingsToSync _
= Array("1", "2", "3", "ABC", "ABC %Total", "123ABC / 321CBA")

For Each myElement In HeadingsToSync
MsgBox myElement
Next myElement
End Sub
 
A

Arturo

testing to see the value

Bob Phillips said:
It is showing 0,1,2,3,4,5 for me one at a time.

Do you really want to show the array index?

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top