The below code works fine when the selected column has more than 5 values. But, when the selected column is empty the code doesn't validate the >5 condition and throws a run time error. Can someone please help?
VBA Code:
abc:
n = Selection.Cells.SpecialCells(xlCellTypeConstants).Count
If n > 5 Then
Set InputRng = Application.Selection
Set ReplaceRng = tblAdmin.Range("M2:N90")
For Each rng In ReplaceRng.Columns(1).Cells
InputRng.Replace What:=rng.Value, Replacement:=rng.Offset(0, 1).Value, LookAt:=xlWhole, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Next
ActiveCell.Next.EntireColumn.Select
GoTo abc