Sub test()
Dim Arr, Ar(1 To 3)
Arr = Range([a1], [a65536].End(3))
y = 2
For i = 1 To UBound(Arr)
For j = 1 To 3
N = N + 1: If N > UBound(Arr) Then GoTo 99
Ar(j) = Arr(N, 1)
Next
Cells(1, y).Resize(3, 1) = Application.Transpose(Ar)
y = y + 1
99: Next
End Sub§@ªÌ: hcm19522 ®É¶¡: 2021-6-22 16:09
Sub test1()
Dim Arr, Ar(1 To 3)
Arr = Range([a1], [a65536].End(3))
x = 1: y = 2
For i = 1 To UBound(Arr)
For j = 1 To 3
N = N + 1: If N > UBound(Arr) Then GoTo 99
Ar(j) = Arr(N, 1)
Next
Cells(x, y).Resize(3, 1) = Application.Transpose(Ar)
If y < 6 Then y = y + 1 Else x = x + 3: y = 2
99: Next
End Sub§@ªÌ: wang077 ®É¶¡: 2021-6-23 16:54
Sub test2()
Dim Arr, Ar(), N%, M%, x%, y%
Arr = Range([a1], [a65536].End(3))
M = Int(UBound(Arr) / 5): x = 1: y = 2
If M < 1 Then
Cells(x, y).Resize(, UBound(Arr)) = Application.Transpose(Arr)
Else
For i = 1 To UBound(Arr)
ReDim Ar(1 To M)
If N = UBound(Arr) Then GoTo 99
If N = M * 5 Then
ReDim Ar(1 To UBound(Arr) - N)
For j = 1 To UBound(Arr) - N: N = N + 1: Ar(j) = Arr(N, 1): Next
Cells(x, y).Resize(, UBound(Ar)) = Ar: Exit For
End If
For j = 1 To M: N = N + 1: Ar(j) = Arr(N, 1): Next
Cells(x, y).Resize(UBound(Ar), 1) = Application.Transpose(Ar)
Erase Ar
If y < 6 Then y = y + 1 Else x = x + M: y = 2
99: Next
End If
End Sub§@ªÌ: wang077 ®É¶¡: 2021-6-23 20:57
¦^´_ 16#samwang
Sub Openfile()
fileToOpen = Application _
.GetOpenFilename("Excel Files(*.csv*), *.csv*", MultiSelect:=True)
num = 0
linenumber = 0
For num1 = 1 To UBound(fileToOpen)
num = num + 1
If fileToOpen(num) <> "False" Then
Open fileToOpen(num) For Input As #1 ' Open file for input
Do While Not EOF(1) ' Loop until end of file
linenumber = linenumber + 1
Line Input #1, line
arrayOfElements = Split(line, ",")
elementnumber = 0
For Each element In arrayOfElements
elementnumber = elementnumber + 1
Cells(linenumber, elementnumber).Value = element
Next
Loop
End If
Close #1 ' Close file.
Next num1
End Sub
³o¬O§Úªºµ{¦¡½X¡A¶}¥X¨ÓªºcsvÀɳ£¬O¶Ã½X
¥Î¤F¿ý¼v¥¨¶°
µo²{¸òTextFilePlatform¦³Ãö
¤j¯«¥i¥HÀ°§Ú¶Ü§@ªÌ: samwang ®É¶¡: 2021-6-25 09:44