ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Array trouble (https://www.excelbanter.com/excel-programming/382634-array-trouble.html)

Arturo

Array trouble
 
*********************
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

Ralph

Array trouble
 
you should probably dim y as an integer and then msgbox HeadingsToSync(y)


"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


Bob Phillips

Array trouble
 
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)



"Arturo" wrote in message
...
*********************
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




Dave Peterson

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

Arturo

Array trouble
 
testing to see the value

"Bob Phillips" wrote:

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)



"Arturo" wrote in message
...
*********************
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






All times are GMT +1. The time now is 12:20 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com