Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim sql As String
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & ThisWorkbook.Path & ";" & _
"Extended Properties='Text;HDR=No'"
sql = "SELECT Col1 FROM abc.csv"
rs.Open sql, cn, adOpenKeyset, adLockOptimistic
如果使用vba从csv文件中没有列标题行,如何按列号选择Col1?
答案 0 :(得分:0)
您可能需要以不同方式处理读取,但此解决方案适合您。
Link to StackOverflow Q/A that will help you
sql = "SELECT * FROM abc.csv"
rs.Open sql, cn, adOpenKeyset, adLockOptimistic
var column1 = "";
Do While Not rsCSV.EOF
column1 = rs.Fields(0)
'Do something with the column1 data
rs.MoveNext
Loop