Excel-获取最后一个填充列中的内容并移动到单独的列

Excel-获取最后一个填充列中的内容并移动到单独的列,excel,excel-formula,excel-2010,excel-2013,Excel,Excel Formula,Excel 2010,Excel 2013,我有多行数据,最后一列中的值需要移动到另一个新列。所以如果我的数据看起来像 一|二|5. 两个|这个|6. 三个|3. | 然后我需要它看起来像 一|二||5. 两个|||6. 三|3. 之前: 考虑: Sub dural() With ActiveSheet.UsedRange nLastColumn = .Columns.Count + .Column - 1 Columns(nLastColumn).Copy Columns(nLastC

我有多行数据,最后一列中的值需要移动到另一个新列。所以如果我的数据看起来像


一|二|5.
两个|这个|6.
三个|3.     |

然后我需要它看起来像

一|二||5. 两个|||6. 三|3.

之前:

考虑:

Sub dural()
    With ActiveSheet.UsedRange
        nLastColumn = .Columns.Count + .Column - 1
        Columns(nLastColumn).Copy Columns(nLastColumn + 1)
        Columns(nLastColumn).Clear
    End With
End Sub
及之后:


这正是您所追求的目标,如果您不理解,请随时探究:

Sub LastClm()

Dim myRng As Range
Dim lRow, lClm, rCnt, cCnt As Integer

lRow = Sheets(4).Cells(Sheets(4).Rows.Count, 1).End(xlUp).Row
lClm = Sheets(4).Cells(1, Sheets(4).Columns.Count).End(xlToLeft).Column

'sets the last row regardless of missing information in the first column
Do Until Application.WorksheetFunction.CountA(Rows(lRow + 1)) = 0
lRow = lRow + 1
Loop

'sets the last column regardless of missing information in the first row
Do Until Application.WorksheetFunction.CountA(Columns(lClm + 1)) = 0
lClm = lClm + 1
Loop

'Loops through each row from back to front taking the first cell it sees with information in it
For rCnt = 1 To lRow
 For cCnt = lClm To 1 Step -1
 With Sheets(4)
    If Application.WorksheetFunction.CountA(.Cells(rCnt, cCnt)) = 1 Then
        .Cells(rCnt, lClm + 1).Value = .Cells(rCnt, cCnt)
        .Cells(rCnt, cCnt).ClearContents
        GoTo 1
    End If
 End With
 Next cCnt
1
Next rCnt

End Sub

看起来格式设置已关闭。。。我很感激任何一个有电脑的人能够改变它,让它变得更清晰:|。我的手机似乎无法正确输入输出。我看不到通过公式实现这一点的方法,但可以通过双VBA循环轻松实现。如果你只是在寻找配方奶粉的解决方案,你可能会想等一位真正的配方奶粉专家来帮忙。我什么都愿意!