我正在尝试删除两列的最后一个单元格。我收到对象不支持此方法的错误。这是我尝试过的:
' Delete last cell of columns C and E
Worksheets("Sheet1").Columns ("C"), Columns("E").End(xlDown).Cells.Delete
谢谢
答案 0 :(得分:0)
您可以使用以下功能清除列中的最后一个单元格
Function ClearLastCell(colLetter As String, Optional ws As Worksheet)
If ws Is Nothing Then
Set ws = ActiveSheet
End If
With ws
.Range(colLetter & .Rows.Count).End(xlUp).Clear
End With
End Function
对于C列和E列,
Sub ClearIt()
Dim ws As Worksheet
Set ws = Worksheets("Sheet1")
ClearLastCell "E", ws
ClearLastCell "C", ws
End Sub