对不起,现在,如何从其他工作簿中删除数据? 我要删除文件Victoria.xlsx中的数据。这不起作用...能帮我吗?谢谢!
Sub BorrarContenidoVictoria()
Dim wbThat As Workbook
Dim wsThat As Worksheet
Dim wbThatPath As String
Dim lRow As Long
'~~> Change path accordingly
wbThatPath = "/Users/jose/Desktop/Victoria.xlsx"
Set wbThat = Workbooks.Open(wbThatPath)
Set wsThat = wbThat.Sheets("Hoja1")
lRow = wsThat.Range("A" & Rows.Count).End(xlUp).Row
wsThat.Range("A2" & lRow).ClearContents
End Sub
答案 0 :(得分:0)
这会删除Hoja1
的{{1}}中的所有单元格:
Victoria.xlsx
Sub BorrarContenidoVictoria()
Dim wbThat As Workbook
Dim wsThat As Worksheet
wbThatPath = "/Users/jose/Desktop/Victoria.xlsx"
Set wbThat = Workbooks.Open(wbThatPath)
Set wsThat = wbThat.Sheets("Hoja1")
wsThat.Cells.Delete
wbThat.Close True
End Sub
关闭工作簿并保存更改-
Close Method MSDN