参考下面的图片,我试图将所有数据点从C列带到最后一个被占用的列(在这种情况下,N,但在其他情况下,它们会有所不同,但不会超过U列)并将它们移动全部到列(AA)作为最后一列,同时删除其间的所有空单元格。
如果有人能帮助我,我真的很感激!
预期输出如下:
答案 0 :(得分:0)
你可能想试试这个
Option Explicit
Sub main()
Dim row As Range
Dim arr As Variant
With Worksheets("AlignSheetName") '<--| change "AlignSheetName" to your actual worksheet name
With Intersect(.UsedRange, .Columns(3).Resize(, .UsedRange.Columns(.UsedRange.Columns.Count).Column - 2))
For Each row In .Rows
arr = Split(WorksheetFunction.Trim(Join(Application.Transpose(Application.Transpose(row.Value)), " ")), " ")
row.ClearContents
row.Cells(1, 1).Offset(, 27 - 3 - WorksheetFunction.CountA(row) - 1).Resize(, WorksheetFunction.CountA(row)).Value = arr
Next row
End With
End With
End Sub