Vba variable not defined

nd0911

Board Regular
Joined
Jan 1, 2014
Messages
117
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
 

Some videos you may like

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.

nd0911

Board Regular
Joined
Jan 1, 2014
Messages
117
Thank you shg, but my code is very organized, all of my varieble's in the code are declared with OPTION EXPLICIT statement's
 

shg

MrExcel MVP
Joined
May 7, 2008
Messages
21,746
Office Version
2010
Platform
Windows
Are you sure that's the error, and not "Sub or function not defined"?
 

Jonmo1

MrExcel MVP
Joined
Oct 12, 2006
Messages
44,061
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 ?
 

nd0911

Board Regular
Joined
Jan 1, 2014
Messages
117
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:

mole999

Moderator
Joined
Oct 23, 2004
Messages
10,286
Office Version
2019, 2016, 2013
Platform
Windows
are they using a non english setup ?
 

shg

MrExcel MVP
Joined
May 7, 2008
Messages
21,746
Office Version
2010
Platform
Windows
Or maybe the user deleted the listbox.
 

Watch MrExcel Video

Forum statistics

Threads
1,095,546
Messages
5,445,116
Members
405,317
Latest member
gcallaway

This Week's Hot Topics

Top