you array is one element "1,2,5,6,7,8"
instead of separate elements
if you're doing it like that, you'd have to use something like the split
function to separate the values
split(num(0),",")
try this with the code you just posted:
add this line
Dim num As Variant
comment out the for next loop lines
then click debug, add a watch and type in num
create a breakpoint on the message box line so the code stops
click the + sign next to num in the watch window. you have one element
once you've seen it, stop the code
now, do the same procedure with the code i posted below, you will have 6
elements
you're better off doing something like this
Sub test()
Dim i As Long, lResult As Long
Dim num As Variant
num = Array(1, 2, 5, 6, 7, 8)
For i = LBound(num) To UBound(num)
lResult = lResult + Worksheets(num(i)).Range("A1").Value
Debug.Print lResult
Next
MsgBox lResult
End Sub