excel vba 清除內容

Step 1 輸入程式碼「Cells.ClearContents」,可以將工作表內所有儲存格清除「內容」
Cells.ClearContents

Step 2 執行後,即可清除工作表中的所有內容,但不會清除格式

Step 3 將程式碼更改為「Cells.Clear」即可將工作表中所有儲存格清除「內容」及「格式」
Cells.Clear

Step 4 若不想清除所有儲存格,可以使用「Range(儲存格或儲存格範圍).ClearContents」來清除儲存格內容
Range("B2:B5").ClearContents
【教學】Excel VBA 如何只清除工作表內容、連格式內容一起清除?