ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Error routine needed (https://www.excelbanter.com/excel-programming/327855-error-routine-needed.html)

Jeff Wright[_2_]

Error routine needed
 
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(xlCellTypeConsta nts).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



David

Error routine needed
 
Hi,
Try this in your routine:
Sub Macro1()
If ActiveCell.Row <= 40 Then
ActiveCell.EntireRow.SpecialCells(xlCellTypeConsta nts).ClearContents
End If
End Sub

Thanks,

"Jeff Wright" wrote:

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(xlCellTypeConsta nts).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





All times are GMT +1. The time now is 03:07 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com