tags:

views:

49

answers:

0

I'm getting a formatting problem when I use UNION ALL under Excel 2007. I have 12 worksheets one for each month I'm trying to apply UNION ALL to combine all the data from these 12 worksheets. Each worksheet has 3 columns 2 with numerical data and one with date. I've had the problem with the last worksheet. My numeric column turns into string (for all month but December) and date (for December) after I merge all tables in a single one. If I add any number of blank columns between the data on my Dec worksheet everything works fine. If I delete any adjacent column everything works fine too.

I'm using Microsoft.ACE.OLEDB.12.0 as my provider and my connection string has worked for several things in my code so far.

Here is my code:

Dim StrOr As String
Dim i As Variant
Dim Cnt As ADODB.Connection
Dim Rs As ADODB.Recordset

For i = 1 To 12
    StrOr = StrOr & " " & "SELECT SC FROM [" & MonthName(i, True) & "$" & "] UNION ALL"
Next

StrOr = Left(StrOr, Len(StrOr) - 9) & ";"

Call GetADOCnt

Call ADORs