Hellow,
我有复制过去代码的问题
我无法识别行中的最后一个单元格"我想要过去的#34; !?
在下一个代码中,我写了" Shet.Cells(Rows.Count," N")。结束(xlUp).row + 1",它运行良好,以防万一没有隐藏的行,除了最后一行的值总是替换自己!!
那么,每次执行Sub Copy_Past()时,我应该怎么做才能更新最后一行的值???
Sub Copy_Past()
Dim Shet As Worksheet
Set Shet = ThisWorkbook.Sheets(1)
Dim LRow As Long
'To get the latest cell in the column "N", where I would like to paste my data.
LRow = Shet.Cells(Rows.Count, "N").End(xlUp).row + 1
'To make a copy form where I selected
Selection.SpecialCells(xlCellTypeVisible).Copy ActiveSheet.Cells(LRow, "M")
'To delete the range of data that I selected and after coping them
Selection.SpecialCells(xlCellTypeVisible).Delete (xlShiftUp)
End Sub
答案 0 :(得分:0)
我找到了解决方案:)
Sub xlCellTypeLastCell_Example_Column()
For LastRow = Columns("N").SpecialCells(xlCellTypeLastCell).row To 1 Step -1
If Len(Cells(LastRow, "N").Formula) Then Exit For
Next
MsgBox LastRow
End Sub