+ Reply to Thread
Results 1 to 20 of 20

Lock Row and Column

  1. #1
    Forum Contributor
    Join Date
    12-08-2018
    Location
    pakistan
    MS-Off Ver
    2013-365
    Posts
    500

    Lock Row and Column

    Hi all,
    i want to lock corsor movement in in specific column like C - D and E means not to enter specific column like C-D and E. when you try to cursor goes to C then it will goto directly f.
    rest of all column will be enter cursor.
    can anybody tell me how is this?

    Thanks

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Lock Row and Column

    You will need a small macro.

    Right Click On Your Sheet Name At the Bottom Of Excel and Select View Code
    Paste this code in the module that opens and close it.

    Save the workbook as macro enabled.

    Please Login or Register  to view this content.
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  3. #3
    Forum Contributor
    Join Date
    12-08-2018
    Location
    pakistan
    MS-Off Ver
    2013-365
    Posts
    500

    Re: Lock Row and Column

    hello mehmetcik,
    thanks to reply. i use this but column C is not lock, D and E are lock, and when move to cursor back from F to A it is nto going to back and stay in F. i want to move cursor back, only C -D-E will be locked.
    Thanks

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Lock Row and Column

    Please clarify,

    It's not clear (at least to me) what you mean by locked.
    Locked with resepect to cell has a very specific meaning when Sheet Protection is switched on.

    Neither do I understand whether you want to prevent columns C/D/E being selected and column F the selected column or whether ONLY C/D/E can be selected.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  5. #5
    Forum Contributor
    Join Date
    12-08-2018
    Location
    pakistan
    MS-Off Ver
    2013-365
    Posts
    500

    Re: Lock Row and Column

    Richard Buttrey Sir,
    actually i have a file to protect it with some range to get formula or change any thing. so i want given range lock first and then cursor movement not working on it.
    like:
    range C2 to E10 totally lock cell and cursor never be entered in these cells. if you goto c2 cursor move to out of this range from left to right.
    if any more clarification then i will send you excel file.
    Thanks.

    Thanks.

  6. #6
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Lock Row and Column

    Have you left all cells as locked(that's the default setting, and are you Protecting the Sheet 'with Format Protect Sheet'?

    When you protect a sheet you are given the options to Select Locked cells AND Select Unlocked cells. However even if you allow selection of locked cells the user can't change them only view them. Does that help?

  7. #7
    Forum Contributor
    Join Date
    12-08-2018
    Location
    pakistan
    MS-Off Ver
    2013-365
    Posts
    500

    Re: Lock Row and Column

    Hi Richard,
    i sending you a file. i revived this from someone, but i dont know this setting. kindly tell me abount this setting i a excel.
    i use this setting in my file.
    thanks.
    Attached Files Attached Files

  8. #8
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Lock Row and Column

    See attached,

    I'm still not sure exactly what you want to happen.
    In this workbook if the user selects a cell in columns C:E the cursor will jump to column F.

    It would have been easier if you had mentioned the password for the protection. However I'm not sure it's absolutely necessary, this one is just protected without a password but apply a password if you wish.
    Attached Files Attached Files

  9. #9
    Forum Contributor
    Join Date
    12-08-2018
    Location
    pakistan
    MS-Off Ver
    2013-365
    Posts
    500

    Re: Lock Row and Column

    Hi, Richard
    there is a difference between your and my file. in your file i cannot goto A to E column. you lock cursor movement at F. in my file only C8 to E12 cursor movement lock and you can move everywhere. kindly tell me about this setting.
    i understand your point if there is no need of protection please leave it but cursor movement lock within the cell.
    kindly generate macro which i can choose myself lock area.
    Thanks.

  10. #10
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Lock Row and Column

    Still not sure I understand what you want.

    If you want to be able to select any column other than columns C:E then change the macro to

    Please Login or Register  to view this content.
    Why do you want a macro to change the cells which are locked.
    As I said earlier all cells are locked by default once Sheet protection is set.

    Just use the Format Cells Protection option to change the 'locked' status

  11. #11
    Forum Contributor
    Join Date
    12-08-2018
    Location
    pakistan
    MS-Off Ver
    2013-365
    Posts
    500

    Re: Lock Row and Column

    Hi Richard,
    i use this code and apply and run it but message come to new window macro name. why this?
    Thanks.

  12. #12
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Lock Row and Column

    What exactly is the error message you get and what line of code is it debugging on?

    Are you sure you edited the original I gave you and are using the Worksheet Selection Change event?

    If you are then please upload the wprkbook you are using.

  13. #13
    Forum Contributor
    Join Date
    12-08-2018
    Location
    pakistan
    MS-Off Ver
    2013-365
    Posts
    500

    Re: Lock Row and Column

    Hi Richard,
    please see the actuall error.
    i dont know enough knowledge regarding VBA coding.
    Thanks.
    Attached Images Attached Images

  14. #14
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Lock Row and Column

    That's not an error. It's simply the normal Excel Macros dialog box. All its telling you is that there is no Module in VBA which contains a macro,

    In VBA there are two sorts of macro.

    There are macros that react to sheet events of various sorts. e.g. double clicking a cell, right clicking a cell, activating a sheet, selecting cell, changing a cell.....and several others. Sheet event macros do NOT appear in the Macos dialog box - simply because you can't run them manually out of choice. They will automatically run if a certain event happens.

    These event macros can be seen when you choose 'Worksheet' in the drop down box in VBA. In the other drop down you can see all the event macros. In the picture you show you can see it is the Selection_Change event. So in your case when you select a cell in columns C:E (which are locked) the cursor jumos to column F. As I said earlier the only reason you can select a column C:E cell at all is because when you Protect the sheet you are given the option to Select Locked cells. It doesn't mean that you can change cells, and in the normal course of events you could select them to see what's in them (but not edit or change). In your case however there is a selecion_change event which takes priority so the second you try to select the cell the cursor goes to column F.

    Macros that you create to do other stuff are created inside a VBA Module which you can create by choosing Insert Module from the VBA menu bar.
    These macros you WOULD see in the Macros dialog box. In your case there aren't any.


    Hope this helps

  15. #15
    Forum Contributor
    Join Date
    12-08-2018
    Location
    pakistan
    MS-Off Ver
    2013-365
    Posts
    500

    Re: Lock Row and Column

    Hi Richard,
    Lets finish this.
    kindly tell me in the new file to apply new setting.
    i want cursor movement not allow in the range of C3 to G13.
    is this possible by simple way means without MACRO or VBA coding?
    if YES please tell me.
    rest of all cell will be treated as normal working.
    protection is nescessry for this setting or NOT?
    please explain in very simple way to apply this setting.
    i use property setting lock scroll setting but in this cursor movement set withing scroll bar area.
    i want cursor not allow in the given range area.
    Thanks.
    Attached Images Attached Images
    Attached Files Attached Files

  16. #16
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Lock Row and Column

    The simplest way to prevent locked cells being selected is to add sheet protection and ensure the 'Select Locked Cells' option is NOT, repeat NOT ticked. i.e. the point I made way back in post #6

    Hence Lock Cells C3:G13, switch on sheet protection and don't allow selection of locked cells.

  17. #17
    Forum Contributor
    Join Date
    12-08-2018
    Location
    pakistan
    MS-Off Ver
    2013-365
    Posts
    500
    Hi richard,
    Can you explain me this step by step.
    I am doing but dont get desired result as my wish.
    Thanks

  18. #18
    Forum Contributor
    Join Date
    12-08-2018
    Location
    pakistan
    MS-Off Ver
    2013-365
    Posts
    500

    Re: Lock Row and Column

    Hi richard,
    I got your point. I do it,
    Thanks for your guidance.
    Thanks

  19. #19
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,917

    Re: Lock Row and Column

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  20. #20
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Lock Row and Column

    Quote Originally Posted by majidsiddique View Post
    Hi richard,
    I got your point. I do it,
    Thanks for your guidance.
    Thanks
    My pleasure, glad to have assisted

+ 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. can v lock column
    By ilyaskazi in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-28-2012, 12:40 PM
  2. [SOLVED] Lock column based on value in one cell column
    By gilly68 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-23-2012, 05:08 PM
  3. try to Lock Column
    By redbaron13183709 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-14-2010, 10:18 AM
  4. lock a column
    By niharika in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-13-2008, 02:10 PM
  5. [SOLVED] How to lock a column
    By Patty via OfficeKB.com in forum Excel General
    Replies: 1
    Last Post: 09-23-2005, 02:05 PM
  6. [SOLVED] Lock Column
    By Shobhit Bhatnagar in forum Excel General
    Replies: 5
    Last Post: 05-14-2005, 11:06 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