0
I made a query in excel that when running it in VBA was generated a result. Among the generated columns, one that was text appeared with #num! in all values that were not empty before.
I believe that excel understood that that column was numerical even if it was not, due to having in the first columns empty values (null).
This macro/query, serves for several routines and did not want to leave locked in the code an if only for this column, or for this template. Is there any way I can’t allow that?
When running the query in access I was successful. But earlier, the same query returned the same error as excel. I can’t understand.
code:
strSQL = "SELECT * FROM " & "[Excel 12.0 Xml;HDR=YES;typeguessrows=0;DATABASE=" & ThisWorkbook.FullName & "].[" & WS14.Name & "$] as Cadastro WHERE " & strexcelcolumnsNotNullKey
Set rs2 = New ADODB.Recordset
strConnectString = "Provider = Microsoft.ACE.OLEDB.12.0; data source=" & strDiretorioPadrao & ";"
Set objConnection = New ADODB.Connection
rs2.Open strSQL, strConnectString
With Sheets("sheet1")
.Cells.ClearContents
.Range("A" & 2).CopyFromRecordset rs2
End With
'Preencher o cabeçalho
x = 0
fim = 0
For Each fld In rs2.Fields
.Cells(1, 1 + x).Value = fld.Name
fim = Application.Max(fim, .Cells(Cells.Rows.Count, 1 + x).End(xlUp).Row)
x = x + 1 'tick iterator
Next
End With
XXXXXXXXXXXXXXXXXX
strsql final: SELECT * FROM [Excel 12.0 Xml;HDR=YES;typeguessrows=0;DATABASE=M: Development Sheets Layout - Base - Desenv_v2_69.25.xlsm]. [Entuba$] as Cadastro WHERE CADASTRO. [Data Posição] is not null AND REGISTER. [Strategy ID] is not null AND REGISTER. [Cashflow ID] is not null AND CADASTRO. [Prazo Médio] is not null AND REGISTER. [Days Overdue] is not null AND REGISTRATION. [Price type] is not null AND CADASTRO. [Financeiro BRL] is not null AND CADAS. [Financial +1 BRL] is not null AND CADASTRO. [Financeiro +2 BRL] is not null AND
Data: (That’s a lot of columns.. I’ll give you an example)
Date Position ID Strategy Strategy Counterparty Total Quantity Free Quantity Collateral Collateral Price Type Term Medium Days in Financial Delay BRL Financial +1 BRL Financial +2 BRL
31/01/2017 54 Go to moon Client Z 5000 1432 0 0
31/01/2017 54 Go to the moon Client Z 5000 1432 0 0.028 0 61.826,15 0,00 0,00
31/01/2017 54 Go to moon Client Z 5000 1432 0 0
31/01/2017 54 Go to moon Client Z 5000 1432 0 0
31/01/2017 54 Go to moon Client Z 5000 1432 0 0
31/01/2017 54 Go to moon Client Z 5000 1432 0 0
31/01/2017 54 Go to the moon Client Z 5000 1432 0 0.00 0.00 0.00 0.00
31/01/2017 54 Go to moon Client Z 5000 1432 0 0
31/01/2017 54 Go to moon Client Z 5000 1432 0 0
31/01/2017 54 Go to moon Client Z 5000 1432 0 0
31/01/2017 54 Go to moon Client Z 5000 1432 0 0
31/01/2017 54 Go to the moon Client Z 5000 1432 0 0.00 0.00 0.00 0.00
31/01/2017 54 Go to moon Client Z 5000 1432 0 0
31/01/2017 54 Go to moon Client Z 5000 1432 0 0
31/01/2017 54 Go to moon Client Z 5000 1432 0 0
31/01/2017 54 Go to moon Client Z 5000 1432 0 0
31/01/2017 54 Go to the moon Client Z 5000 1432 0 0.00 0.00 0.00 0.00
31/01/2017 54 Go to moon Client Z 5000 1432 0 0
31/01/2017 54 Go to moon Client Z 5000 1432 0 0
31/01/2017 54 Go to moon Client Z 5000 1432 0 0
31/01/2017 54 Go to moon Client Z 5000 1432 0 Price A 0
31/01/2017 54 Go to moon Client Z 5000 1432 0 Price B 0.00 0.00 0.00 0.00
31/01/2017 54 Go to moon Client Z 5000 1432 0 Price C 0
31/01/2017 54 Go to moon Client Z 5000 1432 0 Price D 0
31/01/2017 54 Go to moon Client Z 5000 1432 0 Price E 0
31/01/2017 54 Go to moon Client Z 5000 1432 0 Price A 0
31/01/2017 54 Go to moon Client Z 5000 1432 0 Price B 0.00 0.00 0.00 0.00
31/01/2017 54 Go to moon Client Z 5000 1432 0 Price C 0
31/01/2017 54 Go to moon Client Z 5000 1432 0 Price D 0
31/01/2017 54 Go to moon Client Z 5000 1432 0 Price E 0
31/01/2017 54 Go to moon Client Z 5000 1432 0 Price A 0
It would be good for you to add an excerpt of the code and hypothetical table values so that people here can analyze your problem.
– PedroMVM
@Pedromvm, I put the data there. Anyway, I decided by filtering the column before and deleting what was empty. But it is a beautiful of a sledgehammer.
– ART IRUM