Hidden Dan
Board Regular
- Joined
- Dec 7, 2016
- Messages
- 63
Hello,
I got this very simple macro that allows user to erase a complete row. It is manually activated by placing cursor in a certain row/cell and executed by CTRL+SHFT+E.
After deleting row active cell will be A6. This works fine for me. But I would like to incorporate a safety measure. Only that row may be deleted if it contains a certain value.
Suppose my data is placed in A10 : D20. Column A may contain 0 or 1. You may only delete row 12 if value A12 is 0. If A12 would be 1, deletion is prohibited. Similar any row between 10 and 20.
So in practice next will be happen:
- Cursor is placed in cell B12
- Value of A12 is read
- Macro is executed
- if A12 = 0, row is deleted
- if A12 = 1, row is not deleted
- Cursor gets back to A6
How can I add this functionality to my existing script ?
Thanks, Dan
I got this very simple macro that allows user to erase a complete row. It is manually activated by placing cursor in a certain row/cell and executed by CTRL+SHFT+E.
Code:
Sub Erase_item()
ActiveCell.EntireRow.Select
Selection.Delete Shift:=xlUp
Range("A6").Select
End Sub
After deleting row active cell will be A6. This works fine for me. But I would like to incorporate a safety measure. Only that row may be deleted if it contains a certain value.
Suppose my data is placed in A10 : D20. Column A may contain 0 or 1. You may only delete row 12 if value A12 is 0. If A12 would be 1, deletion is prohibited. Similar any row between 10 and 20.
So in practice next will be happen:
- Cursor is placed in cell B12
- Value of A12 is read
- Macro is executed
- if A12 = 0, row is deleted
- if A12 = 1, row is not deleted
- Cursor gets back to A6
How can I add this functionality to my existing script ?
Thanks, Dan