将sheet2表中的数据写入到文本文本中
Sub 转换成txt文件()
Dim f, arr, x, y, k
f = ThisWorkbook.path & "\ruku.txt"
arr = Sheets("sheet2").Range("a1:e6")
Open f For Output As #1
For x = 1 To UBound(arr)
For y = 1 To UBound(arr, 2)
If y = UBound(arr, 2) Then
Print #1, arr(x, y)
Else
If VBA.IsNumeric(arr(x, y)) Then
k = 12 - Len(arr(x, y)) - 2
ElseIf arr(x, y) Like "[A-Z]" Or VBA.IsDate(arr(x, y)) Then
k = 12 - Len(arr(x, y)) - 1
Else
k = 12 - Len(arr(x, y)) * 2
End If
Print #1, arr(x, y); Spc(k);
End If
Next y
k = 0
Next x
Close #1
End Sub
VBA 将sheet2表中的数据写入到文本文本中
最新推荐文章于 2023-12-13 00:01:04 发布