runtime error

D

dnickelson

I'm getting runtime error '9'
Subscript out of range

when running the following function:

Private databaseName As Variant

Private returnArray As Variant

Private queryString As Variant

Private Sub Worksheet_Activate()
databaseName = “Reports”
queryString = "Select * from groups where group_id not like '%a%' and
group_id not like '%z%"
:confused: *returnArray = SQLRequest("DSN=" & databaseName, "Select *
from groups where group_id not like '%a%' and group_id not like '%z%'",
Worksheets(“Sheet1”).Range(“A3”), 2, True)*:confused:
For i = LBound(returnArray, 1) To UBound(returnArray, 1)
For j = LBound(returnArray, 2) To UBound(returnArray, 2)
Worksheets(“Sheet1”).Cells(i, j).Formula = _
returnArray(i, j)
Next j
Next i
End Sub

the highlighted code is returned by debug as the problem area

This error occurs regardless of the query entered, and this is not my
code, I borrowed it from someone nice enough to post the code for
running a SQL query, so I'm not sure where it might be going wrong.

Any Ideas?
 

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