ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to prevent deleting certain rows (https://www.excelbanter.com/excel-programming/333476-how-prevent-deleting-certain-rows.html)

Dory en Ed

How to prevent deleting certain rows
 
Hello experts,


I want to avoid that my users delete certain rows, because they contain
hidden information.
When they delete these rows the functionality will be disturbed.

They are allowed to make others changes in the cells of these rows, just not
to delete the whole row.

I try to find a way to detect this with VBA code and then show a message.
Did some examinations on the Worksheet.Change event, but still have no clue.
It would be good already if it was possible to detect that one or several of
the "forbidden" rows are selected (as whole rows) before deleting them.

Hope you can help, it is very important for me.


Thanks in advance,

Ed van Wijngaarden



Jim Cone

How to prevent deleting certain rows
 
Ed,

You could place your hidden information on another
sheet and hide that sheet.
or
Place some data in the specific rows and then
check to see if it is still there after any change...
'--------------------------------------------------------
'Code goes in the worksheet code module.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim dblAnswer As Double
dblAnswer = WorksheetFunction.Sum(Range("D14:D17")) '1, 2, 3, 4
If dblAnswer < 10 Then
MsgBox "Don't do that"
Application.Undo
End If
End Sub
'------------------------------------------------------

Regards,
Jim Cone
San Francisco, USA


"Dory en Ed" wrote in message
...
Hello experts,
I want to avoid that my users delete certain rows, because they contain
hidden information.
When they delete these rows the functionality will be disturbed.
They are allowed to make others changes in the cells of these rows, just not
to delete the whole row.
I try to find a way to detect this with VBA code and then show a message.
Did some examinations on the Worksheet.Change event, but still have no clue.
It would be good already if it was possible to detect that one or several of
the "forbidden" rows are selected (as whole rows) before deleting them.
Hope you can help, it is very important for me.
Thanks in advance,
Ed van Wijngaarden




All times are GMT +1. The time now is 04:20 PM.

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