Bug in VBA : Error 13

Hello everyone,

I am blocked. When i unload the Userform3 "New product" and i select the company in option button it goes to error.

Can you help to solve my problem

Thank you
Adil KhAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

gowflowCommented:
I guess you need to post a sample workbook that show the error so we can help you.
gowflow
0
Roy CoxGroup Finance ManagerCommented:
What error message are you getting? An example workbook would definitely help.

Where is the Option Button?
0
Fabrice LambertFabrice LambertCommented:
Hi,

Error 13 is a type uncompatibility error.
Alas, without your source code, there is nothing we can do.
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

Adil KhAuthor Commented:
Good afternoon, I attached the file so you can download it

Thank you
0
Martin LissOlder than dirtCommented:
Still no attachment. Did you click the blue 'Upload' button?
0
Adil KhAuthor Commented:
Sorry,

This is the file thank you. Please let me know if it is attached or not
Draft.xlsm
0
Martin LissOlder than dirtCommented:
I believe the problem is in this code in Userform3. At line 10, 'd' is empty.

Private Sub UserForm_Initialize()
Dim D1 As Object, D2 As Object, D3 As Object, D4 As Object
Stop
Set OI = Worksheets("Items")

TV = OI.Range("X1").CurrentRegion
Set D1 = CreateObject("Scripting.Dictionary")

NL = UBound(TV, 1)
Set d = CreateObject("Scripting.Dictionary")
For i = 2 To NL
    D1(TV(i, 1)) = ""
    
Next i
Me.ComboBox4.List = D1.keys
Me.ComboBox4.SetFocus
End Sub

Open in new window

0
Rory ArchibaldCommented:
In Userform3, you set TV using:

TV = OI.Range("X1").CurrentRegion

Open in new window


so the first column is now City names. But in the Optionbutton code in Userform1 you are looking for a Company name in column 1 of TV, which hasn't been reset. As a result, the error arises in BOS here:

Set d = CreateObject("Scripting.Dictionary")
For i = 2 To NL
    If TV(i, 1) = M Then d(TV(i, 2)) = ""
Next i
Me.ComboBox1.List = Application.Transpose(d.keys)

Open in new window


because d is always empty.

This is one of the dangers of public variables. I don't really see why you need to use TV in userform 3 at all. Just use a local variable.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Adil KhAuthor Commented:
Thank you all For your help and solutions.
0
Adil KhAuthor Commented:
I have another problem in the same file should i continue here or create another Question?

Thank you
0
Roy CoxGroup Finance ManagerCommented:
Start a separate question please
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VBA

From novice to tech pro — start learning today.