+ Reply to Thread
Results 1 to 10 of 10

How to make multiple excel columns as non-editable in multiple Tabs using VBA

  1. #1
    Registered User
    Join Date
    02-23-2014
    Location
    Seattle
    MS-Off Ver
    Excel 2010
    Posts
    60

    How to make multiple excel columns as non-editable in multiple Tabs using VBA

    Greetings Excel Forum Team!

    Problem Statement: How to make multiple excel columns as non-editable in multiple Tabs using VBA

    In the attached spreadsheet (Test-ColumCellNonEditable.xlsm - SEP-Test Tab)
    I have column L with specific defined Range(L7 - L22) is made non editable when user clicks on Column L between L7 & L22.

    --------------------------------
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)

    If Not Intersect(Target, Range("L7:L22")) Is Nothing Then
    Target.Offset(, 1).Select
    MsgBox "Executed is Non-Editable"
    End If

    End Sub
    --------------------------------

    User Scenario1: Is it possible to make multiple columns with identified ranges such as below as non editable.

    Column O Range(O7 - O22),
    Column P Range(P7 - P22).


    User Scenario2:If I have multiple Tabs like 'SEP-Test', 'AUG-Test' but each Tab need same columns (L,O,P)need to be non editable but range for each Tab varies
    Is it possible to have single dynamic function that can handle above need, please let me know.

    Appreciate any help with resolution(vba function/proc) for above User Scenario's.
    Thank you.
    Attached Files Attached Files

  2. #2
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    2,760

    Re: How to make multiple excel columns as non-editable in multiple Tabs using VBA

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here
    Click the * Add Reputation button in the lower left hand corner of this post to say thanks.

    Don't forget to mark this thread SOLVED by going to the "Thread Tools" drop down list above your first post and choosing solved.

  3. #3
    Registered User
    Join Date
    02-23-2014
    Location
    Seattle
    MS-Off Ver
    Excel 2010
    Posts
    60

    Re: How to make multiple excel columns as non-editable in multiple Tabs using VBA

    Please Login or Register  to view this content.
    This is the initial code I have but this needs to be tweaked or need new proc to make multiple columns with specific range as non-editable.

  4. #4
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    2,760

    Re: How to make multiple excel columns as non-editable in multiple Tabs using VBA

    What exactly do you want to do. These columns have formulas in them.

    Do you want to lock these cells so no one can change the formulas?

    Do you want code to change the formula into a value and then lock it so it can't be changed?

  5. #5
    Registered User
    Join Date
    02-23-2014
    Location
    Seattle
    MS-Off Ver
    Excel 2010
    Posts
    60

    Re: How to make multiple excel columns as non-editable in multiple Tabs using VBA

    The formula's given in Column O & Column P are accurate as they will get calculated based on formula given.
    I need to lock these cells so no one can change the number driven by formula.

    Basically I would like to lock Column L Range(L7 - L22), Column O Range(O7 - O22), Column P Range(P7 - P22).
    Rest of the column range for Column L, Column O, Column P should be editable.

    The above code I have works only for Column L Range(L7 - L22), is it possible to make multiple columns with specific range as no editable?

  6. #6
    Registered User
    Join Date
    02-23-2014
    Location
    Seattle
    MS-Off Ver
    Excel 2010
    Posts
    60

    Re: How to make multiple excel columns as non-editable in multiple Tabs using VBA

    The formula's given in Column O & Column P are accurate as they will get calculated based on formula given.
    I need to lock these cells so no one can change the number driven by formula.

    Basically I would like to lock Column L Range(L7 - L22), Column O Range(O7 - O22), Column P Range(P7 - P22).
    Rest of the column range for Column L, Column O, Column P should be editable.

    The above code I have works only for Column L Range(L7 - L22), is it possible to make multiple columns with specific range as no editable?

  7. #7
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    2,760

    Re: How to make multiple excel columns as non-editable in multiple Tabs using VBA

    Your code doesn't lock anything. If they click on one of the cells in that range it simply moves the cursor to a different cell and gives them a message. Is that what you want or do you want the cell locked, which is different than what you are doing with your code? If you want to lock the cells you should do it with a password otherwise the user can just unlock the cell manually.

  8. #8
    Registered User
    Join Date
    02-23-2014
    Location
    Seattle
    MS-Off Ver
    Excel 2010
    Posts
    60

    Re: How to make multiple excel columns as non-editable in multiple Tabs using VBA

    I think lock terminology is creating some confusion here.

    The ask seems is very simple, as a user u should not edit columns L, O, P with each range (7 - 22).
    for example, what this means is when u click on or move on to cell L7 it should display the message 'Executed Is Non-Editable'
    similarly
    if user click on O7 it should display the message '%Executed Is Non-Editable',
    if user click on P7 it should display the message '%Passed Is Non-Editable'.

    With my code I could manage for column L (between L7 - L22) to display message 'Executed Is Non-Editable'
    What is missing is similar pattern with different message for column O and P in similar range.
    It would be good If we can define the range and call in procedure but not sure it is possible or not.

  9. #9
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    2,760

    Re: How to make multiple excel columns as non-editable in multiple Tabs using VBA

    I think lock terminology is creating some confusion here.
    Your profile states you have Excel 2010 as do I.
    Right click on any cell, choose "Format Cells", choose the "Protection" tab, notice the check box labeled "Locked".

    In post #6 you said you wanted to lock the cells.

    This code does what your other code did, but on the range you requested. It might do some things you don't like. If someone inserts or deletes columns the code won't run on certain cells depending on what they have done. If you select cells A1 to L7 watch what happens.


    Please Login or Register  to view this content.
    Last edited by skywriter; 09-16-2015 at 03:32 PM.

  10. #10
    Registered User
    Join Date
    02-23-2014
    Location
    Seattle
    MS-Off Ver
    Excel 2010
    Posts
    60

    Re: How to make multiple excel columns as non-editable in multiple Tabs using VBA

    Thanks skywriter!

    Above code works for multiple columns, but what you referred below is correct
    "If you select cells A1 to L7 watch what happens" or if you do ctri+A- This is leading to infinite loop with message box repeated.

    Is it possible to avoid this infinite loop, please let me know.

    I hope there will be a solution for this issue.

+ 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] Extracting data from multiple columns on multiple sheets / tabs etc to a common matrix
    By MagicMan in forum Excel Programming / VBA / Macros
    Replies: 22
    Last Post: 03-26-2015, 07:38 AM
  2. Extracting multiple webpages (1 website, multiple tabs) into excel using a macro
    By Rjk214 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-17-2015, 05:27 PM
  3. [SOLVED] Importing Data from Multiple Excel Forms into Multiple Tabs in New Workbook
    By hollybo in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-20-2014, 03:42 PM
  4. Preventing Duplicate's, Multiple columns & on Multiple Tabs - Validation
    By Victoriak in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-12-2014, 04:22 AM
  5. Excel VBA - If, then, else multiple tabs and multiple columns
    By mikey3580 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 03-11-2014, 03:33 PM
  6. Consolidating multiple files into one excel file with multiple tabs
    By Chemistification in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-13-2012, 06:23 AM
  7. Make specific cells or columns un-editable ?
    By leonhart1981 in forum Excel General
    Replies: 1
    Last Post: 09-08-2011, 02:44 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