Vba variable not defined

Thanks Thanks:  0
Likes Likes:  0
Results 1 to 10 of 10

Thread: Vba variable not defined

  1. #1
    Board Regular
    Join Date
    Jan 2014
    Posts
    96
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Vba variable not defined

     
    Hi there,

    I send a file to someone with VBA code, and he get an error that in my 3 PC's I do NOT get.

    the error message is :"variable not define

    what is worge with his PC

    Does anyone familiar this problem

    TNX

  2. #2
    MrExcel MVP shg's Avatar
    Join Date
    May 2008
    Location
    The Great State of Texas
    Posts
    19,737
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Vba variable not defined

    I think the problem is on your end.

    See Declaring Variables

  3. #3
    Board Regular
    Join Date
    Jan 2014
    Posts
    96
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Vba variable not defined

    Thank you shg, but my code is very organized, all of my varieble's in the code are declared with OPTION EXPLICIT statement's

  4. #4
    MrExcel MVP shg's Avatar
    Join Date
    May 2008
    Location
    The Great State of Texas
    Posts
    19,737
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Vba variable not defined

    Are you sure that's the error, and not "Sub or function not defined"?

  5. #5
    MrExcel MVP Jonmo1's Avatar
    Join Date
    Oct 2006
    Location
    Bryan, TX
    Posts
    43,484
    Post Thanks / Like
    Mentioned
    14 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Vba variable not defined

    Can you post the actual code, and tell us which variable is highlighted when the error occurs?

    Maybe there are missing references
    On the problematic PC, in the VBA window click Tools - References.
    Is there anything listed as Missing ?
    Use the MrExcel HTML Maker to post nicely formatted tables in your forum posts.
    Find a link in post number 31

    The more we learn, and the better we get at our trade, the easier it becomes to overlook the obvious.

    Life moves pretty fast. If you don't stop and look around once in a while, you could miss it.
    Ferris Bueller A.K.A. John Hughes, 1986

  6. #6
    Board Regular
    Join Date
    Jan 2014
    Posts
    96
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Vba variable not defined

    Thank you Jonmo1

    No listed missing (checked)


    the code :

    Code:
    Dim s0 As Worksheet
    Dim s1 As Worksheet
    Dim s2 As Worksheet
    Dim Rng As Range, cl As Range
    
    
    Set s0 = ThisWorkbook.Sheets("EmployeeSelections")
    Set s1 = ThisWorkbook.Sheets("DataBase")
    Set s2 = ThisWorkbook.Sheets("Welcome")
    
    Set Rng = s1.Range("a2:a" & s1.Cells(Rows.Count, "a").End(xlUp).Row)
    
    
    ListBox1.Clear
    
    If s0.Range("a1").Value = "" Then
        ListBox1.Enabled = True
        SubmitWhoAmI.Enabled = True
        
        For Each cl In Rng
            ListBox1.AddItem cl
        Next
        ListBox1.AddItem ""
    Else
        Call ListBox2EmpployeeSelections
    End If
    
    
    End Function
    the marked line is ListBox1.Clear

    and the code is in the Sheet VBE (NOT MODOLE)
    Last edited by nd0911; Jan 11th, 2016 at 12:54 PM.

  7. #7
    Moderator mole999's Avatar
    Join Date
    Oct 2004
    Location
    UK
    Posts
    8,334
    Post Thanks / Like
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Vba variable not defined

    are they using a non english setup ?
    • Yes I know there are better ways to do it. I just wish I knew them. - 2003, 2007, 2010, 2013 & 2016
    • I wear my ignorance openly, excel is not my chosen career, its a means to an ends
    • Posting Guidelines Want to post well laid out questions and answers Translate Excel Versions
      Code:
      [CODE ]Put Your Code[/ CODE]
    • Settings > General Settings (on the left) scroll to the bottom, > Miscellaneous Options > Use ENHANCED
    • X-Posting Guidelines Rule 13 > CHART STUFF

  8. #8
    MrExcel MVP Jonmo1's Avatar
    Join Date
    Oct 2006
    Location
    Bryan, TX
    Posts
    43,484
    Post Thanks / Like
    Mentioned
    14 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Vba variable not defined

    I wonder if it's related to an Office Update that broke some activeX controls last year.
    Office Update breaks ActiveX controls | Excel Matters
    Use the MrExcel HTML Maker to post nicely formatted tables in your forum posts.
    Find a link in post number 31

    The more we learn, and the better we get at our trade, the easier it becomes to overlook the obvious.

    Life moves pretty fast. If you don't stop and look around once in a while, you could miss it.
    Ferris Bueller A.K.A. John Hughes, 1986

  9. #9
    MrExcel MVP shg's Avatar
    Join Date
    May 2008
    Location
    The Great State of Texas
    Posts
    19,737
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Vba variable not defined

    Or maybe the user deleted the listbox.

  10. #10
    MrExcel MVP Jonmo1's Avatar
    Join Date
    Oct 2006
    Location
    Bryan, TX
    Posts
    43,484
    Post Thanks / Like
    Mentioned
    14 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Vba variable not defined

      
    Quote Originally Posted by shg View Post
    Or maybe the user deleted the listbox.
    Or renamed it.
    Use the MrExcel HTML Maker to post nicely formatted tables in your forum posts.
    Find a link in post number 31

    The more we learn, and the better we get at our trade, the easier it becomes to overlook the obvious.

    Life moves pretty fast. If you don't stop and look around once in a while, you could miss it.
    Ferris Bueller A.K.A. John Hughes, 1986

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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

 

 
DMCA.com