mouse click instead of cmdbtn click

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
Hi peeps,

is it possible, if yes then how, to populate textboxes and comboboxes with mouse click or double click. from a listbox
for now i have a cmdbttn that populates the tbx en cbx from my listbox.
but i would rather like a mouse bttn click while scrolling trough my listbox, and than populate the txbx and cbx.

listbox is populated by (rowsource ??)
VBA Code:
Private Sub UserForm_Initialize()
 Dim ws1 As Worksheet, rng1 As Range
 
 Set ws1 = Sheets("Dumpstats")
 Set rng1 = ws1.Range("A1:BH" & ws1.Range("A" & ws1.Rows.Count).End(xlUp).Row)
 
 With Me.ListBox1
        .ColumnHeads = True
        .ColumnCount = rng1.Columns.Count
        .ColumnWidths = "50;30;00;00;50;00;00;00;30;00;00;00;80;150;00;00;100;100;80;40;40;40;00;60;55;50;00;00;00;00;00;70;150;00;00;00;150;00;00;00;60;60;90;200;85;00;00;00;90;00;00;00;00;150;60;00;00;00;00;00"
                       '"00;01;02;03;04;05;06;07;08;09;10;11;12; 13;14;15; 16; 17;18;19;20;21;22;23;24;25;26;27;28;29;30;31; 32;33;34;35; 36;37;38;39;40;41;42; 43;44;45;46;47;48;49;50;51;52; 53;54;55;56;57;58;59"
        .RowSource = rng1.Parent.Name & "!" & rng1.Resize(rng1.Rows.Count - 1).Offset(1).Address
  End With

'add items in comboboxen

        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 'tijd in
        ComboBox7.List = Application.Range("werktijden").value 'tijd uit
        ComboBox8.List = Application.Range("pauze_geen_pauze").value 'pauze
        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.value
                ComboBox10.Enabled = False
                    Next cell
        'ComboBox11.List = Application.Range("adressen").value
        'ComboBox11
        With ComboBox11
              .ColumnCount = 5
                .List = Range("adressen").value
                  End With
        'ComboBox12.List = Application.Range("adressen").value
        'ComboBox11
        With ComboBox12
              .ColumnCount = 5
                .List = Range("adressen").value
                  End With
        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
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Can you use the listbox click event?

VBA Code:
Private Sub ListBox1_Click()

    ' Put code in here to populate the textbox or combobox.

End Sub
 
Upvote 1
Can you use the listbox click event?

VBA Code:
Private Sub ListBox1_Click()

    ' Put code in here to populate the textbox or combobox.

End Sub
how simple...life can be😁😁

thanks that what i needed
 
Upvote 0
how simple...life can be😁😁

thanks that what i needed

There is also a Double Click event.

VBA Code:
Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)

End Sub
 
Upvote 1

Forum statistics

Threads
1,223,893
Messages
6,175,242
Members
452,623
Latest member
russelllowellpercy

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