+ Reply to Thread
Results 1 to 25 of 25

Lock and protect selected excel rows with VBA code

Hybrid View

SmallJack Lock and protect selected... 04-13-2015, 05:29 AM
NeedForExcel Re: Lock and protect selected... 04-13-2015, 05:32 AM
SmallJack Re: Lock and protect selected... 04-13-2015, 05:53 AM
NeedForExcel Re: Lock and protect selected... 04-13-2015, 05:55 AM
SmallJack Re: Lock and protect selected... 04-13-2015, 05:59 AM
NeedForExcel Re: Lock and protect selected... 04-13-2015, 06:05 AM
HaHoBe Re: Lock and protect selected... 04-13-2015, 06:16 AM
SmallJack Re: Lock and protect selected... 04-13-2015, 06:31 AM
NeedForExcel Re: Lock and protect selected... 04-13-2015, 06:35 AM
HaHoBe Re: Lock and protect selected... 04-13-2015, 06:54 AM
SmallJack Re: Lock and protect selected... 04-13-2015, 06:50 AM
NeedForExcel Re: Lock and protect selected... 04-13-2015, 06:58 AM
HaHoBe Re: Lock and protect selected... 04-13-2015, 07:25 AM
NeedForExcel Re: Lock and protect selected... 04-13-2015, 07:28 AM
HaHoBe Re: Lock and protect selected... 04-13-2015, 07:38 AM
SmallJack Re: Lock and protect selected... 04-13-2015, 08:37 AM
SmallJack Re: Lock and protect selected... 04-13-2015, 09:28 AM
HaHoBe Re: Lock and protect selected... 04-13-2015, 09:47 AM
SmallJack Re: Lock and protect selected... 04-13-2015, 09:36 PM
HaHoBe Re: Lock and protect selected... 04-13-2015, 11:36 PM
SmallJack Re: Lock and protect selected... 04-15-2015, 02:14 AM
SmallJack Re: Lock and protect selected... 04-15-2015, 10:58 AM
SmallJack Re: Lock and protect selected... 04-15-2015, 09:06 PM
  1. #1
    Forum Contributor
    Join Date
    12-30-2006
    Location
    Australia
    MS-Off Ver
    2017
    Posts
    151

    Re: Lock and protect selected excel rows with VBA code

    Hi Gurus,

    How to incorporate solution given by Holger (post #13) into using a button to trigger the password lock?

    Thought it'll be more user friendly for users to manually lock the entry only when they've really finished entering the data.

    Thank you.



    - Jack
    Regards,
    Jack

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Lock and protect selected excel rows with VBA code

    Hi, Jack,

    Thought it'll be more user friendly for users to manually lock the entry only when they've really finished entering the data.
    Sorry but to rely on extra action isn´t what I would call user-friendly.

    Sub LockSheet()
    
    Dim lngCtr As Long
    
    Const cstrPW As String = "password"
    
    For lngCtr = 2 To 11
      If WorksheetFunction.CountBlank(Range("B" & lngCtr & ":D" & lngCtr)) = 0 Then
        ActiveSheet.Unprotect cstrPW
        Range("B" & lngCtr & ":D" & lngCtr).Locked = True
      Else
        Range("B" & lngCtr & ":D" & lngCtr).Locked = False
      End If
    Next lngCtr
    ActiveSheet.Protect cstrPW
    
    End Sub
    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

+ 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. [SOLVED] How lock rows and protect cells based on date in first column
    By udaybrown7 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 10-27-2014, 05:47 PM
  2. protect and lock rows
    By tkraju in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-15-2014, 11:46 PM
  3. [SOLVED] How to lock/protect a cell that is selected in a macro range
    By rwstarkey in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-20-2014, 08:09 PM
  4. Marco to Lock/Unlock and Protect/Unprotect Multiple Excel Workbooks
    By Jgonza25 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-22-2013, 03:29 PM
  5. MAcro to lock and unlock cells depending on rows selected.
    By ballack in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-25-2007, 11:04 PM

Tags for this Thread

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