Ok here is my question. Right now I am pulling data from a database through excel. I have been able to specifically choose what information i want to bring out of the database while running queries through VBA. My question is how can I get it to show the out put of a column of numbers. I want to be able to tell it where to start pulling the information from and when to stop pulling it. Here is the code I have so far that pull out specific information.
Any help would be greatly appreciated.
Code:
Private Sub CommandButton1_Click()
'Defining variables
Dim cnOra As ADODB.Connection
Dim rsOra As ADODB.Recordset
Dim db_name As String
Dim UserName As String
Dim Password As String
Dim varInput As String 'variable for first input box
Dim varInput2 As String 'variable for second input box
Dim in3 As Integer 'variable for third input box
Dim in4 As Integer 'variable for fourth input box
Set cnOra = New ADODB.Connection
Set rsOra = New ADODB.Recordset
db_name = "AS"
UserName = "Test"
Password = "Entry"
'Making an ODBC connection according to ADO
cnOra.Open "DSN=" + db_name + ";UID=" + UserName + ";PWD=" _
& Password + ";"
rsOra.CursorLocation = adUseServer
'Running a query
rsOra.Open "select * from APLUS.SUM where Year=2004 and Accnm= 1855", cnOra, adOpenForwardOnly
'Passing on data from the recordset to a variable or cell.
'Notice that the column name or alias is used to address
'data in the recordset.
in3 = 1
in4 = 1
Worksheets("Sheet1").Activate
While Not rsOra.EOF
ActiveSheet.Cells(in4, in3) = CStr(rsOra![GSDR09])
rsOra.MoveNext
Wend
rsOra.Close
cnOra.Close
Set rsOra = Nothing
End Sub
Any help would be greatly appreciated.