Error routine needed

  • Thread starter Thread starter Jeff Wright
  • Start date Start date
J

Jeff Wright

Hi, everyone !



I have a range with data and formulas from A1:F40 (called "Rng"). My
workbook includes a macro (below) which can be initiated by the user,
clearing the contents of any given row, but leaving the formulas intact:



ActiveCell.EntireRow.SpecialCells(xlCellTypeConstants).ClearContents



However, I want to include an error routine in my macro which will prevent
the user from clearing a row if the active cell is not in "Rng."



As usual, your help is greatly appreciated.



Thanks,





Jeff Wright
 
Hi,
Try this in your routine:
Sub Macro1()
If ActiveCell.Row <= 40 Then
ActiveCell.EntireRow.SpecialCells(xlCellTypeConstants).ClearContents
End If
End Sub

Thanks,
 
Back
Top