ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Need help with cells Array (https://www.excelbanter.com/excel-discussion-misc-queries/197990-need-help-cells-array.html)

Ayo

Need help with cells Array
 
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

Lars-Åke Aspelin[_2_]

Need help with cells Array
 
On Thu, 7 Aug 2008 11:44:02 -0700, Ayo
wrote:

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("L 8"))

Hope this helps / Lars-Åke

Gary''s Student

Need help with cells Array
 
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



--
Gary''s Student - gsnu200798


"Ayo" wrote:

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


Jeremiah Johnson

Need help with cells Array
 

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

Dave Peterson

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



Ayo wrote:

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


--

Dave Peterson

Dave Peterson

Need help with cells Array
 
Ps.

c should be declared as a range:

dim c as range

Dave Peterson wrote:

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

Ayo wrote:

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


--

Dave Peterson


--

Dave Peterson


All times are GMT +1. The time now is 08:24 PM.

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