Clear Cells In Worksheet Vba. For example look at the below data. Before I tell you about Clear Contents in VBA let me show how we can delete or clear off the data in the specific range.
Clear data from particular cell: Dim mainworkBook As Workbook. The Range object, which is the representation of a cell (or cells) on your worksheet, is the most important object of Excel VBA. Excel VBA allows you to refer to cells in many different ways, cells refers to single cells only. (Note: it can't refer to multiple cells like This cells property is used to specify a single cell or all cells on the worksheet, where it returns a single cell in the Cells collection.
Cells usually reference a single cell at a time, while Range references a group of cells at once.
This contrasts with formula-based cells, which are recalculated whenever the worksheet changes.
Excel Tip > Excel Macros and VBA > Files, Workbook, and Worksheets in VBA > How to Delete Sheets Without Confirmation Prompts DisplayAlerts is a property of Application object in VBA. How do I delete ONLY the values of a range of cells. that is, leave the formatting in tact. DisplayAlerts = True Dim sheet As Worksheet Set sheet = Sheets.