The first thing you need to do is set up your parametereized query in Access. So, say, Query1 is (where ID is an integer):
SELECT ID FROM Table1 WHERE ID = [MyID];
The brackets around [MyID], if it doesn't resolve to a field name, will be considered a Parameter. Now, say, we want to bring back the record with ID 1. Set up your code in Excel:
Sub testdb()
Dim con As ADODB.Connection
Dim cmd As ADODB.Command
Dim prm As ADODB.Parameter
Dim rs As ADODB.Recordset
Set con = New ADODB.Connection
Set cmd = New ADODB.Command
With con
.Provider = "Microsoft.ACE.OLEDB.12.0"
.Open "H:\WBC\Lukas\STOP.accdb"
End With
With cmd
.ActiveConnection = con
.CommandText = "Query1"
.CommandType = adCmdStoredProc
.Parameters.Append cmd.CreateParameter("MyID", adInteger, adParamInput)
.Parameters("MyID") = 1
End With
Set rs = New ADODB.Recordset
rs.Open cmd
Do Until rs.EOF
Debug.Print rs.Fields("ID").Value
rs.MoveNext
Loop
rs.Close
con.Close
Set cmd = Nothing
Set rs = Nothing
Set prm = Nothing
Set con = Nothing
End Sub
This reference adInteger found in this line
.Parameters.Append cmd.CreateParameter("MyID", adInteger, adParamInput)
should be replaced with the proper constant that represents the variable type (see here: http://www.w3schools.com/ado/met_comm_createparameter.asp) of the Parameter in your query. In your case, you would set the Parameter value that's represented in this line
.Parameters("MyID") = 1
with the value from your cell.
And that's it. So you create the Connection, create a Command object (which is essentially a reference to your Access query), set the Command object's properties, including the parameter, then have the results brought back in a recordset. Then loop through the recordset and do what you want with the values.