+ Reply to Thread
Results 1 to 3 of 3

lock cell content after data input

  1. #1
    Registered User
    Join Date
    08-23-2021
    Location
    USA
    MS-Off Ver
    2019
    Posts
    28

    lock cell content after data input

    Hello; i would like to lock all cells in an excel sheet after a first data input
    i use the code

    ActiveSheet.Unprotect Password:="YourPassword"
    Target.Locked = True
    ActiveSheet.Protect Password:="YourPassword"

    normally it should work fine

    but in that same sheet i had an other code who allow me put in order lines according the number i enter in cell on culumn A
    the used code for that is

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Range("A1").Sort Key1:=Range("A2"), Order1:=xlAscending, Header:=xlYes, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom

    End Sub

    so the problem is thta these two codes don't work together
    it gave me an error message when i click in some cell

    my question :
    how can i use both these codes at the same sheet because i need them both

    thanks

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: lock cell content after data input

    Unprotect the sheet before sorting then reprotect it after.

    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Registered User
    Join Date
    08-23-2021
    Location
    USA
    MS-Off Ver
    2019
    Posts
    28

    Re: lock cell content after data input

    Hello AlpahFrog,
    i tried the code you gave me. it lock all cells, even those of culumn A witch serve to sorting

+ 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. Lock a certain cell only after data has been input
    By ZenK in forum F1 Get the most out of Excel Formulas & Functions
    Replies: 0
    Last Post: 07-23-2020, 08:15 PM
  2. Lock a cell based on another cells content
    By Jalica in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-17-2018, 10:21 AM
  3. Formula to input data based on cell text content format
    By Daniel-plattmounts in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 03-09-2018, 10:49 AM
  4. How to lock a cell content
    By Shadmani in forum Excel General
    Replies: 1
    Last Post: 11-14-2014, 01:13 AM
  5. Lock/unlock specific cells in a row based on another cell content of the same row
    By st_rod000 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-10-2014, 02:58 AM
  6. [SOLVED] Lock cell(s) after data input using macro.
    By kawaitang in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-28-2013, 02:44 PM
  7. Lock Cell Date Format NOT Content
    By mlmaclean in forum Excel General
    Replies: 4
    Last Post: 12-30-2010, 08:00 AM

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