I have a macro that runs a query from an external db. In
the WHERE clause, it will be taking the parameter values
from 2 cells in the sheet. This is what I have ...
Sub Plate()
plateid = Worksheets("sheet1"
.Range("A2"
.Value
wellref = Worksheets("sheet1"
.Range("B2"
.Value
With ActiveSheet.QueryTables.Add(Connection:=Array(Array(
.........
"SELECT ... FROM ... WHERE (OLPTID='" & plateid
& "') AND (PTODWELLREFERENCE='" & wellref & "')" _
)
However, instead, of only allowing the users to enter only
one set of parameters, I would like the user to enter more
than one set ... for ex., user enters parameter values for
A2 & B2, and then another parameter values in A3 & B3, etc
etc. (unlimited). How can I modify my code to loop through the range starting from A2 & B2 and plug in the values to the Where clause to query the db and return the Select values, and then then loop to the next cells A3 & B3?
Thank you!
the WHERE clause, it will be taking the parameter values
from 2 cells in the sheet. This is what I have ...
Sub Plate()
plateid = Worksheets("sheet1"
wellref = Worksheets("sheet1"
With ActiveSheet.QueryTables.Add(Connection:=Array(Array(
.........
"SELECT ... FROM ... WHERE (OLPTID='" & plateid
& "') AND (PTODWELLREFERENCE='" & wellref & "')" _
)
However, instead, of only allowing the users to enter only
one set of parameters, I would like the user to enter more
than one set ... for ex., user enters parameter values for
A2 & B2, and then another parameter values in A3 & B3, etc
etc. (unlimited). How can I modify my code to loop through the range starting from A2 & B2 and plug in the values to the Where clause to query the db and return the Select values, and then then loop to the next cells A3 & B3?
Thank you!