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%"
*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)*
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?
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%"
*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)*
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?