PC Review


Reply
Thread Tools Rate Thread

Array - retrieve certain amount of recods for query

 
 
Douglas Evans
Guest
Posts: n/a
 
      27th May 2010
Hi all.
I'm trying to use for my first time, a single dimension array to use within
an external sql query.
I build the array from column A. This can be a variable amount, from 2 to 800.
However, I can only use 150 rows at a time in the query.
Below is what I have so far, in building the array. It's just the pulling
out of 150 records at a time, or the remainder to put into the sql query.

I will be building the sql query string as such:
bug_number = (bug1,bug2,bug3) --these are the numbers in the array. (must
have comma's between them)
strQuery_main = "select distinct(bug_number) from applied_bugs"

I'm unsure on how to begin pulling out the records in the array. i.e. start
off with a Do Loop then use a For Next statement, and how to actually keep
track of where I am at.

The query return will be put into an array also.

Any assistance would be greatly appreciated.

Cheers,
Dougy

---------------------



Sub QueryBugsProcedure

'Declare variables
Dim rngList As Range
Dim intMax As Integer
Dim rwCnt As Integer
Dim intArray As Integer
Dim Arr() As Long
Dim ArrResults() As Long

'Number of bugs to be included in each sql query (max 250)
intMax = 150

'Count number of bugs
Range("A1").Activate
If ActiveCell.Offset(1, 0) = Empty Then
rwCnt = 1
Else
Range(Selection, Selection.End(xlDown)).Select
rwCnt = Selection.Count
End If

'Create array
ReDim Arr(1 To rwCnt)

For Each c In Selection
If c.Value <> Empty Then
i = i + 1
Arr(i) = c.Value
End If
Next c

'Move to this cell for query return
Range("B12").Activate

'count records in array checkpoint
Debug.Print UBound(Arr)




 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
RE: Array - retrieve certain amount of recods for query SteAXA Microsoft Excel Programming 0 27th May 2010 10:32 PM
How to retrieve last date and amount from columns? =?Utf-8?B?dGZyZW50eg==?= Microsoft Excel Worksheet Functions 5 30th Oct 2006 03:49 AM
Searching a limited amount of rows in a vertical array Joe Miller Microsoft Excel Misc 13 22nd Aug 2006 11:34 AM
...how to filter/query recods =?Utf-8?B?VXdpcHJvZg==?= Microsoft Access Getting Started 1 30th Aug 2005 08:11 PM
Evaluating values in cells (an Array?) and returning a dollar amount Beth Microsoft Excel Worksheet Functions 1 17th Aug 2004 09:02 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:38 PM.