Different ways to clear a range using VBA in Excel
To clear a certain area consists of two steps:
- Specify the range that needs to be cleared
- Select a suitable clear method
As an example, the code below clears everything from the entire worksheet specified with name 'Data' in the workbook in which this code is contained, fast by using limiting the range to UsedRange
Dim wb As Workbook: Set wb = ThisWorkbook Dim ws As Worksheet: Set ws = wb.Sheets("Data") Dim rng As Range: Set rng = ws.UsedRange rng.Clear
Clears all aspects mentioned below: content, Format, comments and more.
Clears all cell comments from the specified range.
Clears the data and formulas from the range. It leaves the formatting intact.
Clears the formatting of the range.
Removes all hyperlinks from the specified range; all other cell content, such as text and formatting will be unaffected
Clears notes and sound notes from all the cells in the specified range.
Clears the outline for the specified range.