+ Reply to Thread
Results 1 to 11 of 11

Sheet Protection Options Changing When Macro Runs

  1. #1
    Registered User
    Join Date
    10-23-2013
    Location
    Calgary
    MS-Off Ver
    Excel 2003
    Posts
    6

    Exclamation Sheet Protection Options Changing When Macro Runs

    Hello,

    I need to allow the user to insert and delete unlocked rows, along with the ability to edit objects after the macro runs. I am having problems finding the proper code in the forums.

    This is the macro I am running:


    Sub Hidebutton()
    ActiveSheet.Unprotect Password:=12345
    Application.ScreenUpdating = False
    Selection.AutoFilter Field:=1, Criteria1:="<>"
    Application.ScreenUpdating = True
    ActiveSheet.Protect Password:=12345
    End Sub


    I found this:

    ActiveSheet.Protect Password:=" ", Contents:=True, DrawingObjects:=False, UserInterfaceOnly:=True, _
    AllowFormattingCells:=True

    It seems to be on the right track but I need help.

    Thanks so much for your time.

  2. #2
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Sheet Protection Options Changing When Macro Runs

    AllowInsertingRows and AllowDeletingRows are the other two properties of the protect method you need to set to true.

  3. #3
    Registered User
    Join Date
    10-23-2013
    Location
    Calgary
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Sheet Protection Options Changing When Macro Runs

    Thanks Yudlungar. I keep getting an error when I type that in. Below is how I have it written.

    Sub Hidebutton()
    ActiveSheet.Unprotect Password:=12345
    Application.ScreenUpdating = False
    Selection.AutoFilter Field:=1, Criteria1:="<>"
    Application.ScreenUpdating = True
    ActiveSheet.Protect Password:=12345, Contents:=True, DrawingObjects:=False, UserInterfaceOnly:=True, _
    AllowInsertingRows:=True
    AllowDeletingRows:=True
    End Sub

    Thanks for your time

  4. #4
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Sheet Protection Options Changing When Macro Runs

    You need to put them as part of the protect method, i.e.
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    10-23-2013
    Location
    Calgary
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Sheet Protection Options Changing When Macro Runs

    Thanks yudlugar. This does work up until I change or move the picture with in my unlocked cells on the sheet . It gives me the error "Object doesn't support this property or method". I need to have the ability to change/move the picture in the unlocked section anytime after the macro runs and still have the macro work at any time.

    Thanks for your time

  6. #6
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Sheet Protection Options Changing When Macro Runs

    What is the code you are using to move the picture? I'd guess you should be using incrementleft and incremenettop?

    Does the code work when your sheet is unprotected.

    It would be very helpful if you could upload a workbook.

  7. #7
    Registered User
    Join Date
    10-23-2013
    Location
    Calgary
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Sheet Protection Options Changing When Macro Runs

    I am not using any code to move or manipulate the picture. I am doing it manually since it will have to be inserted and sized on a project by project basis. How would I upload the work book?

  8. #8
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Sheet Protection Options Changing When Macro Runs

    Click go advanced on the reply window and then attachments.

    I'm confused though, the object doesn't support this property error is a vba error - but you say you are moving it manually?

  9. #9
    Registered User
    Join Date
    10-23-2013
    Location
    Calgary
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Sheet Protection Options Changing When Macro Runs

    Here is the workbook simplified to the single page. Thanks for helping out.
    Attached Files Attached Files

  10. #10
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Sheet Protection Options Changing When Macro Runs

    I'm still not sure what the problem you have is so apologies if this is nonsense, but, are you trying to move the picture and then running the macro with the picture still selected? If so, you will be trying to autofilter the picture, which would return the object doesn't support this method error you refer to.

  11. #11
    Registered User
    Join Date
    10-23-2013
    Location
    Calgary
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Sheet Protection Options Changing When Macro Runs

    Yudlugar, you are completly correct that I still had the picture selected which was causing me my issues. Thanks for everything.

+ 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] Macro only runs on specific sheet name
    By cymraeg in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-28-2013, 03:43 PM
  2. Macro only runs on sheet i recorded it on.
    By BF15 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 09-20-2011, 07:15 AM
  3. Changing sheet protection in 'real time' with VBA ?
    By BaLLZaCH in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-01-2008, 01:48 PM
  4. Changing sheet protection
    By Niddeh in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-19-2007, 06:34 AM
  5. [SOLVED] Why is Sheet deleted when Macro runs...
    By Darin Kramer in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-11-2006, 09:55 AM

Tags for this Thread

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