+ Reply to Thread
Results 1 to 4 of 4

Privasate Sub to unprotect sheet when selected

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    07-12-2018
    Location
    South Africa
    MS-Off Ver
    Office 2021
    Posts
    2,780

    Privasate Sub to unprotect sheet when selected

    I have a sheet called "Adjustments"


    I have tried to write code so that when a user creates a range name in the bar to the left of the formula bar or when sheet is selected, the sheet will be unprotected. There is no password used

    Kindly check and amend my code

     Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
        Dim ws As Worksheet
        Set ws = Sh
        
        If ws.Name = "Adjustments" Then
           rotect the sheet
            ws.Unprotect
            
            ' Check if the selected cell is within the range where you enter range names
            If Not Intersect(Target, ws.Range("B1:B2000")) Is Nothing Then
                
                
            
            End If
        End If
    End Sub
    End Sub [/code]

  2. #2
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,520

    Re: Privasate Sub to unprotect sheet when selected

    Private Sub Worksheet_Activate()
    ActiveSheet.Unprotect
    End Sub
    Good Luck...
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the [★ Add Reputation] to left of post window...
    Also....Add a comment if you like!!!!
    And remember...Mark Thread as Solved...
    Excel Forum Rocks!!!

  3. #3
    Forum Contributor
    Join Date
    07-12-2018
    Location
    South Africa
    MS-Off Ver
    Office 2021
    Posts
    2,780

    Re: Privasate Sub to unprotect sheet when selected

    Thanks Sintek

  4. #4
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,520

    Re: Privasate Sub to unprotect sheet when selected

    All good...Tx for rep +

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. VBA unprotect sheet refresh OLEDB connection Protect sheet with exceptions
    By MarcoZanin in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-16-2020, 04:27 AM
  2. [SOLVED] Protect/Unprotect selected worksheets in a workbook
    By acsishere in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-18-2017, 10:34 AM
  3. EXCEL VBA: Unprotect and Protect Sheet [Hidden Sheet]
    By himaruasuka in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-26-2016, 09:06 AM
  4. [SOLVED] Macro to Unprotect Sheet, Paste then Protect Sheet
    By tokyojo1 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-09-2014, 02:02 PM
  5. [SOLVED] Trying to copy selected items from sheet to listbox then selected back to sheet
    By BigWes1960 in forum Excel - New Users/Basics
    Replies: 4
    Last Post: 03-14-2013, 03:27 PM
  6. [SOLVED] unprotect selected row
    By peter001 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-03-2013, 05:25 AM
  7. Macro to unprotect sheet - run macros - then unprotect sheet is not working
    By AnnieBrownTX in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-15-2012, 06:59 PM

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