LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 138
Default Array problem

I have an array which I want to assign an array of varabiles set by a
worksheet reference. Is this a multidimensional array?

Anyway myArr part of the code works fine but I cannot get myVar to.

In case I am thinking of this the wrong way this is what I am trying to
do......

myArr is an array of strings that I loop through to specify a worksheet.
The 2nd dimension is that each worksheet needs to be assigned a value from
another worksheet, however changes pending on the elemet in myArr. myVar
represents the secondary array.

To strat with I just want to return the value of myVar using MsgBox
(myVar(k))

Any ideas?

Bruce



Sub mySec()

Dim myVar(1 To 6)
Dim myArr
ReDim myArr(1 To 6)

pathA = ThisWorkbook.Path & "\ASX.mdb"
pathB = ThisWorkbook.Path

myArr = Array("Sec1", "Sec2", "Sec3", "Sec4", "Sec5", "Sec6")

myVar(1) = Array(Sheets("Shares").Range("D7"))
myVar(2) = Array(Sheets("Shares").Range("F7"))
myVar(3) = Array(Sheets("Shares").Range("H7"))
myVar(4) = Array(Sheets("Shares").Range("J7"))
myVar(5) = Array(Sheets("Shares").Range("L7"))
myVar(6) = Array(Sheets("Shares").Range("N7"))

k = 1

For Each a In myArr

MsgBox (myVar(k))

With Worksheets(a).Range("A1").QueryTable
.Connection = _
"ODBC;DSN=MS Access Database;DBQ=" & pathA & _
";DefaultDir=" & pathB & ";DriverId=25;FIL=MS
Access;MaxBufferSize=2048;PageTimeout=5;"

.CommandText = Array( _
"SELECT Top 30 ImportDate, ASXCode, Volume, Open, High, Low,
Close" & Chr(13) & "" & Chr(10) & _
"FROM qry_ASX_Data" & Chr(13) & "" & Chr(10) & "", _
"WHERE (ASXCode='NAB')" & Chr(13) & "" & Chr(10) & _
"ORDER BY ImportDate DESC")

.FillAdjacentFormulas = True
.Refresh BackgroundQuery:=False
End With

k = k + 1

Next a

End Sub

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Array problem, I think.. Steve Excel Worksheet Functions 3 June 11th 08 12:38 AM
Array problem - TIA S Davis Excel Worksheet Functions 9 November 7th 06 02:22 AM
Array Problem Scott Excel Discussion (Misc queries) 4 May 9th 06 05:22 PM
Array Problem?? Michael Vaughan Excel Programming 6 November 12th 04 02:38 AM
array use problem NikkoW Excel Programming 5 May 5th 04 01:32 AM


All times are GMT +1. The time now is 09:41 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"