+ Reply to Thread
Results 1 to 4 of 4

VBA Compile Error

  1. #1
    Registered User
    Join Date
    06-23-2025
    Location
    United States
    MS-Off Ver
    Office 365
    Posts
    1

    VBA Compile Error

    Thank you everyone who replied! The code is good, but there was non-breaking spaces or invisible characters that caused the compile error for me. After removing those, it ran successfully! So excited for my first VB! Thanks again!

    First time posting and first time using VB in Excel. I am trying to write a VB program to format all the tabs in my Excel file to make sure every tab has the same font and size. Below is my code. When I run F5 to run, it gave me "Compile error: Syntax error". Please help. Thanks.

    Below is what I did.
    Press Alt + F11 to open the VBA Editor in Excel.
    Go to Insert > Module.
    I copied the below code into the Module window. Then I pressed F5 to run. I received "Compile error: Syntax error".
    Please Login or Register  to view this content.
    Last edited by mamawanttolearn; 06-24-2025 at 07:08 PM. Reason: Problem Solved

  2. #2
    Valued Forum Contributor MikeVol's Avatar
    Join Date
    12-30-2020
    Location
    Odessa / Ukraine
    MS-Off Ver
    MSO Prof Plus 2021 x64 (En)
    Posts
    566

    Re: VB Compile Error

    Hello @mamawanttolearn
    No any error on my side, code work fine!
    Please Login or Register  to view this content.
    NOTE: As the original poster/owner, only you can mark your thread as SOLVED (Thread Tools above Post #1).
    You can say "Thanks" in your thread to everyone who offered to help you.
    You can also reward them by clicking * "Add Reputation" under their username on the left.
    With Regards, MikeVol.

  3. #3
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2505
    Posts
    27,209

    Re: VB Compile Error

    Welcome to the Forum mamawanttolearn !

    Administrative Note:

    We recommend that you include code tags around your code. I have added them for you since it's your first post.

    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, and it also maintains VBA formatting.

    Please see Forum Guideline #2 about code tags and adjust accordingly. Click on Edit to open your post, then 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.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2505
    Posts
    27,209

    Re: VB Compile Error

    I tried it too, no syntax error and it ran to completion.

    Double check that what you pasted into the editor is exactly what you showed us here. Maybe when you did the "copy" you missing something.

+ 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. Compile Error: Syntax Error to Compile Error: Argument Not Optional
    By auguste in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-06-2023, 12:46 PM
  2. Compile Error: compile error constant expression required.
    By countryfan_nt in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-30-2019, 04:45 AM
  3. [SOLVED] Compile Error: Wrong number of arguments or invalid property assignment Error
    By JJFletcher in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-22-2016, 05:29 PM
  4. Excel macro (compile error. syntax error.) error
    By salar_younis in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-06-2014, 06:11 AM
  5. [SOLVED] Compile Error in Hidden Module and Compile Error: Can't find project or library
    By Taislin in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 08-10-2013, 07:03 PM
  6. compile error: compile error expected
    By odeno in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-11-2008, 04:30 PM
  7. [SOLVED] VBAProject name compile error, not defined at compile time
    By Matthew Dodds in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-13-2005, 03:20 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