-1

有没有办法自动排列这些数据

在此处输入图像描述

进入这个

在此处输入图像描述

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

我需要的是向下复制 A 列数据,但只复制到下面的空白单元格,然后对新文件夹 id 再次执行此操作,依此类推。

4

2 回答 2

1

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

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

我前段时间写了它,所以它可能能够删除/合并行,但它应该可以工作(假设你只是试图将数据复制到 A 列)。

于 2015-10-09T18:59:31.197 回答
0

在 Excel 中,选择左侧列,开始 > 编辑,查找和选择,转到特殊...,检查空白(仅限),确定,然后选择所选单元格之一,=, Up, Ctl+ Enter

于 2015-10-09T22:15:56.130 回答