+ Reply to Thread
Results 1 to 4 of 4

VBA Compile Error: Expected End Sub

  1. #1
    Registered User
    Join Date
    09-21-2017
    Location
    SLC, Utah
    MS-Off Ver
    2016
    Posts
    7

    VBA Compile Error: Expected End Sub

    Howdy:

    I have a very simple macro to unprotect a tab, refresh a pivot table on that tab and reprotect the tab:

    Please Login or Register  to view this content.
    When I run the macro, I get an Expected End Sub error even though I clearly have an End Sub statement. What am I doing wrong? Thx.
    Last edited by alansidman; 01-18-2021 at 01:45 PM.

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2403 Win 11 Home 64 Bit
    Posts
    23,811

    Re: VBA Compile Error: Expected End Sub

    Code Tags Added
    Your post does not comply with Rule 2 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 at http://www.excelforum.com/forum-rule...rum-rules.html



    (I have added them for you today. Please take a few minutes to read all Forum Rules and comply in the future.)
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Registered User
    Join Date
    09-21-2017
    Location
    SLC, Utah
    MS-Off Ver
    2016
    Posts
    7

    Re: VBA Compile Error: Expected End Sub

    Sorry about that. As you can probably tell, I'm a novice. Thanks for adding the tags.

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,091

    Re: VBA Compile Error: Expected End Sub

    There's nothing wrong with the code presented here. It compiles ok for me.

    Do you have another module with code in it?
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


+ 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] compile error expected: (
    By kevinu in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-27-2018, 03:10 AM
  2. Compile Error: Expected End With
    By Sanjibghosh in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-30-2017, 06:48 AM
  3. [SOLVED] compile error expected sub
    By citypro in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-04-2015, 11:06 AM
  4. Compile error: Expected End Sub
    By MacroCoder in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-06-2013, 04:05 PM
  5. Compile Error: Expected End With?
    By Jeka__7 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-27-2013, 10:30 AM
  6. Compile error: Expected End Sub
    By Leeboy in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-31-2011, 09:44 AM
  7. Compile Error: Expected End Sub
    By Lothar69 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-27-2011, 10: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