Need help with cells Array

A

Ayo

For Each sht In Sheets(Array("NSB West 2008", "NSB West 2009", "NSB East
2008", "NSB East 2009", "NSB Manhattan"))

I am trying to use the line of code below, just like the one above but I am
getting a Method 'Range' of object '_Global' failed. Any ideas?
Thanks.

For Each c In Range(Array("D8", "F8", "H8", "J8", "L8")).Cells
 
L

Lars-Åke Aspelin

For Each sht In Sheets(Array("NSB West 2008", "NSB West 2009", "NSB East
2008", "NSB East 2009", "NSB Manhattan"))

I am trying to use the line of code below, just like the one above but I am
getting a Method 'Range' of object '_Global' failed. Any ideas?
Thanks.

For Each c In Range(Array("D8", "F8", "H8", "J8", "L8")).Cells


Try this instead:

For Each c in Array(Range("D8"),Range("F8"),Range("J8"),Range("L8"))

Hope this helps / Lars-Åke
 
G

Gary''s Student

How about making an array of strings and get the Range set from them:

Sub dural()
s1 = "D8,F8,H8,J8,L8"
s2 = Split(s1, ",")
For i = 0 To UBound(s2)
Set c = Range(s2(i))
MsgBox (c.Address)
Next
End Sub
 
J

Jeremiah Johnson

Sub ParisHiltonForPresident()
Dim arr As Variant
Dim c As Variant
Dim rng As Range

arr = Array("D8", "F8", "H8", "J8", "L8")
For Each c In arr
Set rng = Range(c)
MsgBox rng.Text
Next
Set rng = Nothing
End Sub



"Ayo"
wrote in message
For Each sht In Sheets(Array("NSB West 2008", "NSB West 2009", "NSB East
2008", "NSB East 2009", "NSB Manhattan"))
I am trying to use the line of code below, just like the one above but I am
getting a Method 'Range' of object '_Global' failed. Any ideas?
Thanks.

For Each c In Range(Array("D8", "F8", "H8", "J8", "L8")).Cells
 
D

Dave Peterson

For Each c In Range("D8,F8,H8,J8,L8").Cells


For Each sht In Sheets(Array("NSB West 2008", "NSB West 2009", "NSB East
2008", "NSB East 2009", "NSB Manhattan"))

I am trying to use the line of code below, just like the one above but I am
getting a Method 'Range' of object '_Global' failed. Any ideas?
Thanks.

For Each c In Range(Array("D8", "F8", "H8", "J8", "L8")).Cells
 

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