There are lots of ways of connecting to databases through vba each has their own requirements... say for example you want to connect through ADODB.... Make sure the VBA IDE has the Microsoft ActiveX Data Objects 2.x Library checked under references under the Tools menu....
Below is a slim'd down version of the connection and queries assuming you need two queries open at the same time.... The connection is made when you need it and closed when your finished withit
'Make sure the Tools/References Microsoft ActiveX Data Objects 2.X is checked
'Or Modify code below if you are using something other than an ADO connection
Dim sQL1 As String, sQL2 As String
Dim cn As ADODB.Connection
Dim rs1 As ADODB.Recordset, rs2 As ADODB.Recordset
Set cn = New ADODB.Connection
cn.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=.\Test.accdb;Persist Security Info=False"
sQL1 = "Select * from Table1;"
sQL2 = "Select * from Table2;"
Set rs1 = New ADODB.Recordset
Set rs2 = New ADODB.Recordset
rs1.Open sQL1, cn
rs2.Open sQL2, cn
Range("A10").CopyFromRecordset rs1
Range("D10").CopyFromRecordset rs2
rs1.Close
rs2.Close
Set rs1 = Nothing
Set rs2 = Nothing
cn.Close
Set cn = Nothing
above code was tested! Note: You will be unable to use the built in Data Refresh commands in Excel. You will have to manage the refreshing of data your self through code...
Bookmarks