+ Reply to Thread
Results 1 to 5 of 5

VBA Protect - allow editing, not allow formatting or inserting columns

  1. #1
    Registered User
    Join Date
    05-05-2015
    Location
    Calgary, Alberta
    MS-Off Ver
    2013
    Posts
    5

    VBA Protect - allow editing, not allow formatting or inserting columns

    I am trying to write a macro that protects a sheets formatting - most specifically the cell size and margins. But I want to allow the cells themselves to be edited. I can't figure out what the correct settings are for this with the Protect command. I keep finding examples that do the opposite.

    This is my current code and it doesn't stop columns from being inserted.

    Sub SetProtection()
    '
    ' SetProtection Macro
    '

    ActiveSheet.Protect UserInterfaceOnly, Contents:=False, AllowInsertingColumns:=False


    End Sub

    What am I doing wrong?

    Thanks,
    Deanna

  2. #2
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,222

    Re: VBA Protect - allow editing, not allow formatting or inserting columns

    Suppose you want to allow editing of two cell ranges: A3:G10 and B15:J30. You select the ranges in question, choose "Formatting cells" from the pop-up menu, select the Protection tab in the new window and uncheck the "Blocked" CheckBox. Now you can apply protection to the sheet.
    The above actions can be performed with a macro:
    Please Login or Register  to view this content.
    Artik

  3. #3
    Registered User
    Join Date
    05-05-2015
    Location
    Calgary, Alberta
    MS-Off Ver
    2013
    Posts
    5

    Re: VBA Protect - allow editing, not allow formatting or inserting columns

    So this can only be done with a range and not with the whole sheet then?

  4. #4
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,222

    Re: VBA Protect - allow editing, not allow formatting or inserting columns

    But all the cells in the worksheet are also a range.
    Please Login or Register  to view this content.
    Artik

  5. #5
    Registered User
    Join Date
    05-05-2015
    Location
    Calgary, Alberta
    MS-Off Ver
    2013
    Posts
    5

    Re: VBA Protect - allow editing, not allow formatting or inserting columns

    Ah... I get it now. Thank you!

    Deanna

+ 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. Prevent inserting and deleting columns with VBA (without using protect sheet)
    By inoka in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-05-2018, 03:28 AM
  2. Formatting Question - Merged Cells and Inserting Columns
    By MaineMan1 in forum Excel General
    Replies: 2
    Last Post: 07-23-2016, 12:33 AM
  3. Inserting columns with specific number of cells and formatting
    By Rooban1993 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-21-2016, 08:57 PM
  4. Replies: 5
    Last Post: 03-10-2016, 06:55 PM
  5. Protect text box from deletion but allow editing
    By Jerbinator in forum Excel General
    Replies: 0
    Last Post: 02-12-2016, 08:33 AM
  6. Password Protect Editing Cells
    By Jason Carlos in forum Excel General
    Replies: 4
    Last Post: 11-22-2015, 09:52 PM
  7. How to protect a workbook for editing only?
    By puneetarora_12 in forum Excel General
    Replies: 1
    Last Post: 03-15-2005, 01:34 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