+ Reply to Thread
Results 1 to 2 of 2

detect any (entire) row selection in entire sheet and unprotect?

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    06-18-2012
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    106

    detect any (entire) row selection in entire sheet and unprotect?

    hello!


    Looking for the following code:


    sheet is currently locked (enabled for locked cell selection).

    VBA detects if any whole row(s) say 21, 22 are selected and automatically unprotects sheet.

    THEN:

    if these exact rows are deleted.. sheet automatically protects again.

    If the user deselects these rows.. sheet protects again.

    (this is design to perform specific row deletion)

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    
    IF 
    
    Rows("1:1").Select
    AND OR
    Rows("2:2").Select
    AND OR
    Rows("3:3").Select
    .
    .
    Rows("1000:1000").Select
    
    Then 
    
    ActiveSheet.Unprotect
    
    Then if
    
    ActiveCell.Row.delete 
    
    ActiveSheet.Protect
    
    End sub



    Your thoughts,

    Thanks!
    Last edited by niceguy21; 01-30-2013 at 11:56 AM.

  2. #2
    Forum Contributor
    Join Date
    06-18-2012
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    106

    Re: detect any (entire) row selection in entire sheet and unprotect?

    Quote Originally Posted by niceguy21 View Post
    hello!


    Looking for the following code:


    sheet is currently locked (enabled for locked cell selection).

    VBA detects if any whole row(s) say 21, 22 are selected and automatically unprotects sheet.

    THEN:

    if these exact rows are deleted.. sheet automatically protects again.

    If the user deselects these rows.. sheet protects again.

    (this is design to perform specific row deletion)

    [/CODE]

    Your thoughts,

    Thanks!
    
    If Selection.Address = ActiveSheet.EntireRow.Address Then
    
    ActiveSheet.Unprotect
    something like this?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1