高分悬赏~excel如何将多列不规则数据合并成一列,数据量很庞大,列数不...
发布网友
发布时间:2024-10-21 12:00
我来回答
共3个回答
热心网友
时间:2024-11-18 14:28
Sub test()
Dim i&, j&, k&
Range("F1:F65536").ClearContents
k = 1
For i = 1 To 65536
If WorksheetFunction.CountA("A" & i & ":D" & i) = 0 Then Exit Sub
For j = 1 To 4
If Cells(i, j) <> "" Then
Cells(k, "F") = Cells(i, j)
k = k + 1
End If
Next
Next
End Sub
热心网友
时间:2024-11-18 14:29
函数挺痛苦,用VBA好了。
Sub ABC()
Dim arr
Dim R As Long, i As Long
Dim x As Integer
R = Range("a65536").End(xlUp).Row
For i = 1 To R
x = Application.WorksheetFunction.CountA(Range("a" & i & ":d" & i))
arr = Range("a" & i, Cells(i, x))
Range("f" & Range("f65536").End(xlUp).Row + 1).Resize(x, 1) = Application.Transpose(arr)
Next
End Sub
热心网友
时间:2024-11-18 14:24
使用宏吧,可以录制一下宏,然后让它执行