Hi I have a list of names and other information in a excel list that I'm preparing for a house party. What I want to do is have the results shown in the immediate window. The information I want is the Name and Sex of the Male only. How do I do that in VBA.
Below I have the code that I have till now!!!
Please help!!!
Sub Query2()
Dim database As ADODB.Connection
Dim students As ADODB.Recordset
Dim SQL As String
Set database = ConnectDB
' define filter
SQL = "SELECT * FROM Data"
' start and run query
Set students = database.Execute(SQL)
' display in Immediate Window
Do Until students.EOF
Debug.Print students!Name, students!sex
students.MoveNext
Loop
' copy results to excel
Range("F2").CopyFromRecordset students
' close properly
students.Close
database.Close
End Sub
Below I have the code that I have till now!!!
Please help!!!
Sub Query2()
Dim database As ADODB.Connection
Dim students As ADODB.Recordset
Dim SQL As String
Set database = ConnectDB
' define filter
SQL = "SELECT * FROM Data"
' start and run query
Set students = database.Execute(SQL)
' display in Immediate Window
Do Until students.EOF
Debug.Print students!Name, students!sex
students.MoveNext
Loop
' copy results to excel
Range("F2").CopyFromRecordset students
' close properly
students.Close
database.Close
End Sub
Last edited: