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,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top