Thread: Array trouble
View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Array trouble

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


Arturo wrote:

*********************
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 doesnt y display anything other than 0?

Sincerely,
Arturo


--

Dave Peterson