Excel vba clear content from row 2 code example

Example 1: excel vba clear contents and formatting of cell with a single command

'To clear a worksheet range from VBA, use one of
'the 'Clear' methtods:

[A1].Clear           '<-- clears everything in the Range cells
[A1].ClearFormats    '<-- clears only the formats
[A1].ClearContents   '<-- clears values but not formats
[A1].ClearHyperlinks '<-- clears hyperlinks only
[A1].ClearNotes      '<-- clears notes only

Example 2: excel vba delete empty rows

' Deletes empty rows
dim rRange As Range, rowsCount As Long, i As Long
Set rRange = ActiveSheet.Range("A1:B100")
rowsCount = rRange.rows.Count
For i = rowsCount To 1 Step -1
    If WorksheetFunction.CountA(rRanges.rows(i)) = 0 Then 
        rRange.rows(i).Delete
    End If
Next

Tags:

Vb Example