Sorry Bat17, but oh yes you can. this is what i referred to in previous post.
remember, when you set up a query using the wizard, you have the opportunity to add criteria? this routine uses that...
'################################################
Sub refresh_it()
Application.ScreenUpdating = False
'obtain the value that is in your workbook
dbase = Range("g1").Value
'set up the string to pass to MSQuery or whatever it is!
sql_connect = Array("SELECT `Table Query`.`Short description`, `Table Query`.Table, `Table Query`.Field, `Table Query`.Description" & Chr(13) & "" & Chr(10) & "FROM `C:\MyFolder\MyDatabase`.`Table Query` `Table Query`" & Chr(13) & "" & Chr(10) & "WHERE (`Table Query`.Table='" & dbase & "')")
'select the data query area
Range("b2").Select
'with that, run the refresh
With Selection.QueryTable
.Connection = Array(Array( _
"ODBC;DBQ=C:\MyFolder\MyDatabase.mdb;DefaultDir=C:\Myfolder;Driver" _
), Array( _
"={Microsoft Access Driver (*.mdb)};DriverId=25;FIL=MS Access;ImplicitCommitSync=Yes;MaxBufferSize=512;MaxScanRows=8;PageTimeout" _
), Array("=5;SafeTransactions=0;Threads=3;UID=admin;UserCommitSync=Yes;"))
.Sql = sql_connect
.Refresh False
End With
Range("g1").Select 'er, if you want to that is
Application.ScreenUpdating = True
End Sub
'#########################
notice how i concatenated the value "dbase" (i'm rubbish at keeping to naming conventions!), and splice it into the SQL statement.
this is called from a double click event on my particular spreadsheet.. a button or whatever would do as well.
------------------------------------------------------------------------
the tip here, is to use my code as inspiration, not in actuality ... start by creating a data query in excel. then, record a macro, and during this, click on the query area, right click, refresh. Stop recording and you SHOULD have all the connection bullsh1t ready written for you.
------------------------------------------------------------------------
mail or PM me if you need more specific help