I want to directly write the result of my sql query in specific cells I am using ADO Excel VBA.
SetConn ' SET THE CONNECTION TO THE DATABASE.
sQuery = "SELECT * FROM [referenceStandard$] WHERE [Line] = 'L1' AND [Variants] = 'Choco Wafer (L1)' AND [ID] = 'CW (L1)' "
If rs.State = adStateOpen Then
rs.Close
End If
rs.CursorLocation = adUseClient
rs.Open sQuery, myConn, adOpenKeyset, adLockOptimistic
If rs.RecordCount > 0 Then
MsgBox "Result is > 1"
Do While Not rs.EOF
'Codes that will copy the result of query and paste in worksheet cells
Loop
End If