重新排列列中的数据

Rearrange data in a column

有什么办法可以自动排列这些数据

进入这个

使用 excel/google sheets/etc。基本上我有一个巨大的文件列表(第二列),我需要映射到它各自的文件夹(第一列 ID)。

我需要的是将 A 列数据向下复制,但只复制到紧接其下方的空白单元格,然后为新文件夹 ID 再次执行此操作,依此类推。

我刚好有一个宏可以提示用户将数据复制到哪一列。请参阅以下内容(请注意,您可能需要根据需要进行调整):

Sub GEN_USE_Copy_Data_Down()
Dim screenRefresh$, runAgain$
Dim lastRow&, newLastRow&
Dim c       As Range
Dim LastRowCounter$
Dim columnArray() As String

screenRefresh = MsgBox("Turn OFF screen updating while macro runs?", vbYesNo)
If screenRefresh = vbYes Then
    Application.ScreenUpdating = False
Else
    Application.ScreenUpdating = True
End If


Dim EffectiveDateCol As Integer
LastRowCounter = InputBox("What column has the most data (this info will be used to find the last used row")

CopyAgain:
With ActiveSheet
    lastRow = .UsedRange.Rows.Count
End With


' THIS WILL ASK THE USER TO SELECT THE COLUMN TO COPY DATA DOWN
MsgBox ("Now, you will choose a column, and that column's data will be pasted in the range" & vbCrLf & "below the current cell, to the next full cell")
Dim Column2Copy As String
Column2Copy = InputBox("What columns (A,B,C, etc.) would you like to copy the data of?  Use SPACES, to separate columns")
columnArray() = Split(Column2Copy)

Dim startCell As Range


For i = LBound(columnArray) To UBound(columnArray)
    Debug.Print i
    Column2Copy = columnArray(i)

    Set startCell = Cells(1, Column2Copy).End(xlDown)
    Do While startCell.row < lastRow
        If startCell.End(xlDown).Offset(-1, 0).row > lastRow Then
            newLastRow = lastRow
        Else
            newLastRow = startCell.End(xlDown).Offset(-1, 0).row
        End If
        Set CopyFrom = startCell
        Range(Cells(startCell.row, Column2Copy), Cells(newLastRow, Column2Copy)).Value = CopyFrom.Value
        Set startCell = startCell.End(xlDown)
    Loop
Next i

If screenRefresh = vbYes Then
    Application.ScreenUpdating = True
Else
    Application.ScreenUpdating = True
End If


End Sub

我不久前写的,所以它可能有行 removed/combined,但它应该可以工作(假设您只是尝试将数据复制到 A 列)。

在 Excel 中,select 左侧栏,开始 > 编辑,查找 & Select,转到特殊...,检查空白(仅),确定,然后 select 选择的单元格之一,=, Up, Ctl+输入.