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

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
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,551
Messages
6,179,470
Members
452,915
Latest member
hannnahheileen

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