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

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
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,375
Messages
6,119,168
Members
448,870
Latest member
max_pedreira

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