Problem importing tables with MS Query due to lack of column headers

Glory

Well-known Member
Joined
Mar 16, 2011
Messages
640
Code:
SELECT *
FROM `C:\Documents and Settings\gendetlab\Desktop\hwvdata`.`'Sheet1$'` `'Sheet1$'`
UNION ALL
SELECT * 
FROM `C:\Documents and Settings\gendetlab\Desktop\hwvdata2`.`'Sheet1$'` `'Sheet1$'`


This code works perfectly, except that I have to make column headers bold before they MSQuery will recognize the tables as 'valid'.

If I have to open the files to make the column headers bold, the entire purpose of the code (to speed up the copying process) will be defeated.

Can you help explain why this is happening? Is there a way to force MSQuery to recognize the used range of a sheet as a table, no matter what its contents look like?

To just, treat the first row as a series of column headers?
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
And, now I'm noticing that making the column headers bold isn't a sure-fire solution.

The only way will be to force MSQuery to recognize what it grabs from each sheet as its own table.

Is there any way to force that behavior?
 
Upvote 0

Forum statistics

Threads
1,224,542
Messages
6,179,424
Members
452,914
Latest member
echoix

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