1.插入按钮,在开发工具项-插入表单工具-Button
2.导入代码
Sub Inport_Renkei_CSV_Click()
Dim fTextDir As String, rowIndex As Integer, i As Integer
myFile = Application.GetOpenFilename("连携CSVファイル(*.csv),*.csv")
If VarType(myFile) = vbBoolean Then
Exit Sub
End If
rowIndex = 1
Open myFile For Input As #1
Do While Not EOF(1)
Line Input #1, currLine
If rowIndex > 1 Then
rowDataArr = Split(currLine, Chr(9))
For i = 0 To UBound(rowDataArr)
Cells(rowIndex + 1, i + 1).FormulaR1C1 = rowDataArr(i)
Next i
End If
rowIndex = rowIndex + 1
Loop
Close #1
MsgBox "success"
End Sub
追问导入之后CSV文件的格式完全变了,csv文件中是有数据与数据之前空白单元格的