Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default How to detect a col/row deletion?

I want to detect this event in order to avoid the deletion of some critical
columns.

Any ideas on what event would fire?

Thanks,
MV


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default How to detect a col/row deletion?

I would recommend against this course of action, going instead for the cell
protection feature which is available. You can lock cells and then protect
the worksheet so the locked cells can't be deleted. You can optionally
specify a password as well.

If, however, you require the functionality you requested, this code is a
STARTING point; tested in Excel XP. It will NOT work in XL97, and I didn't
test it in XL 2000:

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Static bUndoing As Boolean

If Target.Address = "$C:$C" Then
If Not bUndoing Then
bUndoing = True
Application.Undo
Else
bUndoing = False
End If
End If
End Sub

Instead of the very simple target.address line above, you'll have to check
to see if the target is within any set of cells you choose. Check out the
Intersect vba method for ideas of how to do that.

Please note - there are numerous ways things can be selected and deleted.
For example, if the user has a multiple selection range and deletes, you'd
have to test each range in the multiple selection to see if it falls in your
desired protection area. (Try adding this code at the beginning of the code
above for debugging purposes: Application.StatusBar = Target.Address).

I think, therefore, that this is going to be a difficult thing to do; I'd
strongly recommend going with protection instead.
--
HTH -

-Frank
Microsoft Excel MVP
Dolphin Technology Corp.
http://vbapro.com




"Mauricio Villada" wrote in message
...
I want to detect this event in order to avoid the deletion of some

critical
columns.

Any ideas on what event would fire?

Thanks,
MV




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
need to detect syntax in value J.Parker Excel Discussion (Misc queries) 1 February 13th 10 05:09 AM
Detect Duplicates Jakobshavn Isbrae Excel Worksheet Functions 5 April 25th 08 07:40 PM
How to detect #N/A and return 0? Eric Excel Discussion (Misc queries) 2 May 30th 07 06:12 AM
How to detect changes in a column? inomata Excel Discussion (Misc queries) 0 December 14th 05 08:26 PM
how to detect 5th character? nastech Excel Discussion (Misc queries) 4 October 31st 05 11:31 AM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"