Consulting

Results 1 to 12 of 12

Thread: VBA Code not running if sheets are protected

  1. #1
    VBAX Regular
    Joined
    Sep 2019
    Posts
    57
    Location

    VBA Code not running if sheets are protected

    Hi there all
    I have three workbooks that are linked
    If I protect the sheets the VBA code does not work
    Specifically looking for problem in the monthly shopping list

    Please assist
    Attached Files Attached Files

  2. #2
    VBAX Master paulked's Avatar
    Joined
    Apr 2006
    Posts
    1,007
    Location
    Specifically looking for problem in the monthly shopping list
    That's not specific, it's a needle in a haystack!!! Which workbook of the three? We could guess. Which code isn't running? What line does it fail on? Which sheets in which workbooks are you protecting? etc etc...

    If you want help, please help us too!
    Semper in excretia sumus; solum profundum variat.

  3. #3
    VBAX Regular
    Joined
    Sep 2019
    Posts
    57
    Location
    In the monthly shopping list workbook
    on the start menu sheet if i try to clear old menus, fill menu nos
    and in the shopping list sheet if line 8 is protected and i use the dropdown months......the menu numbers dont update.

  4. #4
    VBAX Master paulked's Avatar
    Joined
    Apr 2006
    Posts
    1,007
    Location
    I did:
    Protected Shopping List Sheet
    Start Menu sheet, chose Menu 24, Clear Old Menus, Fill Menu No's.
    Shopping List sheet, changed Month to July

    The data changed on the Shopping List sheet.
    Semper in excretia sumus; solum profundum variat.

  5. #5
    VBAX Regular
    Joined
    Sep 2019
    Posts
    57
    Location
    Protect sheets and try process again. then it doesnt work

  6. #6
    VBAX Master paulked's Avatar
    Joined
    Apr 2006
    Posts
    1,007
    Location
    Which sheets? What doesn't work? I am not a mind reader and have no idea what is supposed to happen so "it doesn't work" is totally meaningless. It 'worked' for me because some numbers changed.
    Semper in excretia sumus; solum profundum variat.

  7. #7
    VBAX Master paulked's Avatar
    Joined
    Apr 2006
    Posts
    1,007
    Location
    What is 'normal' when working with protected sheets is:

    Sub Ked()
        Sheet1.Unprotect
        'Do stuff on Sheet1
        '...
        Sheet1.Protect
    End Sub
    Semper in excretia sumus; solum profundum variat.

  8. #8
    VBAX Regular
    Joined
    Sep 2019
    Posts
    57
    Location
    If you protect start menu and calendar menu, it does not allow me to make changes

    was hoping that something like UserInterFaceOnly:=True would help

  9. #9
    VBAX Master paulked's Avatar
    Joined
    Apr 2006
    Posts
    1,007
    Location
    Start Menu I can see, but Calendar Menu doesn't exist!
    Semper in excretia sumus; solum profundum variat.

  10. #10
    VBAX Regular
    Joined
    Sep 2019
    Posts
    57
    Location
    SORRY YOU ARE CORRECT.
    IT WAS CHANGED TO YEAR PLANNER

  11. #11
    VBAX Master paulked's Avatar
    Joined
    Apr 2006
    Posts
    1,007
    Location
    Sub Del12Months()
        Dim i As Integer, j As Integer, r As Range, c As Range
        
        Application.EnableEvents = False
        Application.ScreenUpdating = False
        'Application.Calculation = xlCalculationManual
    
    
        With Worksheets("Year Planner")
        'With ActiveSheet
            .Unprotect
            For i = 7 To 52 Step 15
                '1st row of 3 months menus
                Set r = Range(.Cells(i, "A"), .Cells(i, "W")).Offset(3)
                For j = 0 To 10 Step 2
                    Set c = r.Offset(j)
                    c.ClearContents
                Next j
            Next i
            .Protect
        End With
        
        Application.EnableEvents = True
        Application.ScreenUpdating = True
        Application.Calculation = xlCalculationAutomatic
    End Sub
    An similar for any other subs
    Semper in excretia sumus; solum profundum variat.

  12. #12
    VBAX Regular
    Joined
    Sep 2019
    Posts
    57
    Location
    THANK YOU

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •