Query's

G

Guest

Guest
Is it possible when getting external data in to Excel, to run multiple query's that load data on to individual worksheets of 1 workbook?
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
You can use DAO to get data by SQL strings easily.

'This routine opens sample.xls file then uses the sqlstr string as SQL text then retrieves data by given criteria. You can create multiply queries with this way.

Sub GetData()
'Reference : DAO 3.6 object library
Dim dbmain As Database
Dim rcset As Recordset
Dim sqlstr As String
Dim i As Integer
Set dbmain = OpenDatabase("c:windowsdesktopsample.xls", False, False, "Excel 8.0;")
sqlstr = "SELECT * FROM [Jan2002$] WHERE Code<100000"
Set rcset = dbmain.OpenRecordset(sqlstr)
Do Until rcset.EOF
i = i + 1
ActiveSheet.Cells(i, 1).Value = rcset.Fields(1).Value
ActiveSheet.Cells(i, 2).Value = rcset.Fields(2).Value
rcset.MoveNext
Loop
Set rcset = Nothing
Set dbmain = Nothing
End Sub

regards
Suat
(You can visit TheWordExpert for VBA help and also other office applications)
 
Upvote 0
On 2002-03-14 07:03, Anonymous wrote:
Is it possible when getting external data in to Excel, to run multiple query's that load data on to individual worksheets of 1 workbook?

Yes, using the Data | Get External Data menu command.
 
Upvote 0

Forum statistics

Threads
1,214,806
Messages
6,121,672
Members
449,045
Latest member
Marcus05

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top