Fault 1004 range of object aplication failed on userform.show

DB73

Board Regular
Joined
Jun 7, 2022
Messages
107
Office Version
  1. 365
  2. 2021
  3. 2019
  4. 2016
  5. 2010
  6. 2007
Platform
  1. Windows
  2. Mobile
  3. Web
Hey guys,

another problem to solve for me
i have a sheet with some buttons, 1 is for showing my userform (MyForm)

Code to show userform;
VBA Code:
Private Sub CommandButton1_Click()
MyForm.Show
End Sub
this 1 is on sheet18(gegevens invoer)

This 1 is on the userform;
Code to load the cmbxs;
VBA Code:
Private Sub UserForm_Initialize()

        ComboBox1.List = Application.Range("werkdag_ziek_verlof").value
        ComboBox2.List = Application.Range("projecten").value
        ComboBox3.List = Application.Range("adressen").value
        ComboBox4.List = Application.Range("normale_uren_over_uren").value
        'ComboBox5.List = Application.Range("uur_tarief_percentage").value
        'cbx5
            Dim cell As Range
             For Each cell In Application.Range("uur_tarief_percentage").Cells
                ComboBox5.AddItem cell.Text
                    Next cell
        ComboBox6.List = Application.Range("werktijden").value
        ComboBox7.List = Application.Range("werktijden").value
        ComboBox8.List = Application.Range("pauze_geen_pauze").value
        ComboBox9.List = Application.Range("BTW_verlegd").value
        'ComboBox10.List = Application.Range("BTW_heffing").value
        'cbx10
            For Each cell In Application.Range("btw_heffing").Cells
                ComboBox10.AddItem cell.Text
                    Next cell
        'ComboBox11.List = Application.Range("adressen[klantnaam]").value
        'ComboBox11
            With ComboBox11
              .ColumnCount = 5
                .List = Range("adressen").value
                  End With
        ComboBox12.List = Application.Range("adressen[klantnaam]").value
        ComboBox13.List = Application.Range("enkel_retour_rit").value
        ComboBox14.List = Application.Range("woon_werk_zakelijk").value
        ComboBox15.List = Application.Range("te_declareren_per_km").value
        ComboBox16.List = Application.Range("overige_declaratie").value
        ComboBox17.List = Application.Range("reden_rit").value
        ComboBox18.List = Application.Range("te_declareren_per_km").value
        ComboBox19.List = Application.Range("vervoer").value
        ComboBox20.List = Application.Range("reden_overige_declaratie").value
End Sub

on my search on the WWW i found that it could be a UserForm_Initialize() that causes the problem.
so i skipped items on the UserForm_Initialize() part to look which line causes the problem, but i cant figur out which one.
if i remove the whole code it seems to work and the userform pops up but, without the comboboxes population

any help on this one will be apreciate
 
In the VB Editor goto Tools, Options, General, & check the "Break in class module"
That way when it fails you can click the debug button & it will takes you to the problem.
u mean ;
1682357662164.png

sorry, , its in dutch for me, but the lay out is kindy the same i think
 
Upvote 0

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
I was saying the error looked to be at this line.
oh..ok...thats what i could find, but i think with the reply of fluff, i hope i can find it now...if thats the case what he meant
 
Upvote 0
its in dutch for me, but the lay out is kindy the same i think
That's the one you need to select so that it highlights the problem line in the initialize event, rather than the userform.Show line
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top