+ Reply to Thread
Results 1 to 5 of 5

Block cell editing after pressing Enter key

  1. #1
    Registered User
    Join Date
    11-23-2020
    Location
    Brasil
    MS-Off Ver
    Professional Plus 2019
    Posts
    2

    Block cell editing after pressing Enter key

    Good night,

    I'm a beginner in Excel and would be very grateful if someone can help me ...

    I would like that after pressing the Enter key, there would be the blocking of cells for editing ...

    In other words, the idea is that when inserting data in a cell, when pressing the Enter key, that cell is blocked for editing (the other cells must remain unlocked until the Enter key is clicked on them) and that eventual changes are allowed only after unlocking with password.

    I am currently using the code below, but the blocking of the cells occurs immediately after entering data and I need the blocking to occur only after pressing the Enter key.

    Private Sub Worksheet_Change(ByVal Target As Range)
    ActiveSheet.Unprotect Password:
    Target.Locked = True
    ActiveSheet.Protect Password: = "MyPassword"
    End Sub


    Thank you for your help

  2. #2
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    365 Pro Plus
    Posts
    1,602

    Re: Block cell editing after pressing Enter key

    Possibly...
    Please Login or Register  to view this content.
    ____________________________________________________________
    If I've been helpful, let me know. If I haven't, let me know that too.

  3. #3
    Registered User
    Join Date
    11-23-2020
    Location
    Brasil
    MS-Off Ver
    Professional Plus 2019
    Posts
    2

    Re: Block cell editing after pressing Enter key

    Thank you very much for the reply Dangelor!

    The problem with the code you sent is that just add any information that the cell is blocked, even without using the Enter key ...

    I would like the lock to occur only after using the Enter key

  4. #4
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    365 Pro Plus
    Posts
    1,602

    Re: Block cell editing after pressing Enter key

    I guess I don't understand what it is you want... sorry and good luck with your quest.

  5. #5
    Forum Contributor
    Join Date
    06-02-2019
    Location
    libya
    MS-Off Ver
    2010
    Posts
    463

    Re: Block cell editing after pressing Enter key

    hi, guys actually I'm very beginner in vba but i try to help you i think to understand you
    after Mr. dangelor i would add this code indeed I've found in the internet and mod the code but work for me as far understand the question
    put this in module
    HTML Code: 
    Sub myMacro()
     Application.EnableEvents = False
        ActiveSheet.Unprotect "MyPassword"
        
        Cells.Locked = False
        ActiveSheet.UsedRange.SpecialCells(xlCellTypeConstants).Locked = True
        ActiveSheet.Protect "MyPassword"
        Application.EnableEvents = True
    End Sub
    and this in event workbook
    HTML Code: 
    Private Sub Workbook_Open()
     Application.OnKey "~", "myMacro"
    End Sub
    note : becareful when press enter any cell is filled will protect
    Last edited by ABDELFATTA; 11-24-2020 at 07:26 PM.

+ 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. Go to specific cell after pressing Enter
    By bush1282 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 03-25-2019, 12:40 PM
  2. [SOLVED] Need To Simulate Pressing Enter Key On A Cell Every Second
    By Ourkid123uk in forum Excel General
    Replies: 12
    Last Post: 02-28-2018, 10:28 AM
  3. instead of editing cell and pressing enter to change format
    By benjamind11 in forum Excel General
    Replies: 1
    Last Post: 01-23-2013, 11:01 AM
  4. Reselect cell after pressing enter
    By randell.graybill in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-19-2010, 10:38 PM
  5. Alt + Enter when pressing enter in cell?
    By Stiff in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-20-2009, 05:31 AM
  6. Editing Cells by Pressing F2 (Coloured cell refs)
    By certain_death in forum Excel General
    Replies: 2
    Last Post: 04-02-2009, 11:35 AM
  7. Active Cell after pressing the Enter Key
    By RealNewbie in forum Excel General
    Replies: 2
    Last Post: 10-17-2007, 09:56 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