EXCEL VBA Questions and Answers

Write a macro to select all the non-blank cells of Activesheet?

Sub NonBlankCells()
On Error Resume Next
Union(Cells.SpecialCells(xlCellTypeFormulas, 23), Cells.SpecialCells(xlCellTypeConstants, 23)).Select
If Err.Number 0 Then
Cells.SpecialCells(xlCellTypeFormulas, 23).Select
Else
Exit Sub
End If
If Err.Number 0 Then
Cells.SpecialCells(xlCellTypeConstants, 23).Select
Else
Exit Sub
End If
On Error GoTo 0
End Sub