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: 25
Default Another Array quetion, sheesh

Ok. I have got my program running to where it will take the data in the array
and based on that data take more data out of access and paste it into various
Excel worksheets. I have hard coded what each cell in the array is so that
vba can do this. My problem is I am going to have arrays of various size. One
might be 200 lines and another might be 3 lines of data. Is there anyway to
program vba to figure out that the array is different and instead of looping
through 5 lines of data it will loop through 200? Here is the code I have for
defining the array. Thanks for any help. I know these questions on arrays are
getting old.


Option Explicit

Private mcnToDatabase As Connection
Private mwksResults As Excel.Worksheet


Private Const STATE_FIPS_COL = 0
Private Const COMMODITY_COLUMN = 1
Private Const PRACTICE_COL = 2
Public Const dbpath = "D:\Profiles\cherring\Desktop\New
Folder\DevelopIndexOut_no_Price_vol.mdb"



Private Const CS = "Provider=Microsoft.Jet.OLEDB.4.0;User
ID=Admin;Mode=Share Deny None;Jet OLEDB:Engine Type=4;Data Source="

Private Const CLIENT_TAB = "CLIENT"
Private Const ALT_TAB = "ALT1"

Sub MainMacro1()






Call Run(dbpath)


End Sub
Public Sub Run(dbpath As String)

Dim lDataRow As Long
Dim lData As Long
Dim alData() As Long

'Set asData = info in Excel

alData = GetAllData




For lDataRow = 0 To UBound(alData, 1) - 1
Main dbpath, alData(lDataRow, STATE_FIPS_COL), alData(lData,
COMMODITY_COLUMN), alData(lData, PRACTICE_COL)

'RunSolver
'Save as new workbook
'Next lDataRow
Next lDataRow
End Sub

Private Function GetAllData() As Long()
Dim alTemp() As Long

ReDim alTemp(2, 3)

Set mwksResults = Application.Worksheets("mwksResults")

With mwksResults
mwksResults.Activate

alTemp(0, 0) = .Range("A2").Value
alTemp(0, 1) = .Range("B2").Value
alTemp(0, 2) = .Range("C2").Value
alTemp(1, 0) = .Range("A3").Value
alTemp(1, 1) = .Range("B3").Value
alTemp(1, 2) = .Range("C3").Value
End With

GetAllData = alTemp

Erase alTemp
End Function
 
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
Prevent cell/array references from changing when altering/moving thecell/array nme Excel Discussion (Misc queries) 1 September 19th 08 01:53 PM
Another Quetion about lookups with errors JD Excel Worksheet Functions 4 July 25th 07 07:34 PM
Passing value to userform quetion Doug Glancy Excel Programming 0 December 1st 06 09:02 PM
meaning of : IF(Switch; Average(array A, array B); array A) DXAT Excel Worksheet Functions 1 October 24th 06 06:11 PM
Array problem: Key words-Variant Array, single-element, type mismatch error davidm Excel Programming 1 November 8th 05 04:21 AM


All times are GMT +1. The time now is 10:37 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"