+ Reply to Thread
Results 1 to 4 of 4

UserForm_Initialize() Gives Compile Error: Expected Function or Variable

  1. #1
    Registered User
    Join Date
    10-17-2023
    Location
    Kingston, Ontario
    MS-Off Ver
    Excel 365 (2016)
    Posts
    3

    UserForm_Initialize() Gives Compile Error: Expected Function or Variable

    Hi everyone!

    I'm very new to coding using VBA so this may be an easy solve.

    I'm trying to make a userform, and have just made a textbox value empty and added items to comboboxes. This code is in the userform itself:

    Please Login or Register  to view this content.
    -----------------------------------

    The user form is called RecordEntryForm, and in my Sheet1 code, I have:

    Please Login or Register  to view this content.
    -----------------------------------

    When I try to run this, I get 'Compile Error: Expected Function or Variable' and it highlights the 'Private Sub UserForm_Initialize()' line.

    I've tried replacing UserForm with name of the actual form -> Private Sub RecordEntryForm_Initialize() - the error goes away but the form values are empty, there are no options for the comboboxes.

    Please advise on what to do here. I have nothing in the 'Modules'.

    -shasabhi1
    Last edited by shasabhi1; 10-22-2023 at 12:19 PM.

  2. #2
    Valued Forum Contributor
    Join Date
    12-30-2020
    Location
    Odessa / Ukraine
    MS-Off Ver
    2021
    Posts
    302

    Re: UserForm_Initialize() Gives Compile Error: Expected Function or Variable

    Hello @shasabhi1. Try next code:
    Please Login or Register  to view this content.
    Good luck.

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

    Re: UserForm_Initialize() Gives Compile Error: Expected Function or Variable

    Or improve the code this way:
    Instead of:
    Please Login or Register  to view this content.
    insert
    Please Login or Register  to view this content.
    Artik

  4. #4
    Registered User
    Join Date
    10-17-2023
    Location
    Kingston, Ontario
    MS-Off Ver
    Excel 365 (2016)
    Posts
    3

    Re: UserForm_Initialize() Gives Compile Error: Expected Function or Variable

    Thank you! This solved my issue. Appreciate your help!

+ 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] ADODB.recordset.find gives a compile error expected function or variable
    By Leon V (AW) in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-25-2022, 05:36 AM
  2. Compile Error: Expected Function or variable
    By bigmon in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-20-2020, 09:22 AM
  3. Getting compile error expected function or variable
    By mso3 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-10-2014, 01:33 AM
  4. [SOLVED] Shell Function "Compile Error: Expected procedure, not variable"
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 08-09-2014, 01:20 PM
  5. [SOLVED] Compile Error Expected Function or Variable
    By shiser in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 05-22-2014, 09:18 AM
  6. [SOLVED] Compile error expected function or variable (on protect method)
    By Tirren in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-30-2013, 03:22 PM
  7. Compile Error:- expected function or variable problem
    By skin.uk1 in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 07-08-2011, 02:56 PM

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