prevnt item selection on a userform/listbox when open

tryagain

Board Regular
Joined
Mar 15, 2010
Messages
102
Hi folks
I have a ListBox on a Userform, populated wit lot of names, adresses aso.
User have to find wanted name and then click on it and selection values writes to sheet
Problem is that when i open Userform, the already selected item is writed to sheet
even before user find and click wanted name.
Hav do i prevent this auto-selection when open ?

Private Sub ListBox1_Click()
ActiveCell = Sheets("Personelliste").Cells(Me.ListBox1.ListIndex + 3, 2)
ActiveCell.Offset(1).Select
If CheckBox1 = True Then Unload Me
End Sub

thanks in advance
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.

Andrew Poulsom

MrExcel MVP
Joined
Jul 21, 2002
Messages
73,092
Then what is causing the ListBox's Click to fire? You could try using ListBox1_Change instead.
 

tryagain

Board Regular
Joined
Mar 15, 2010
Messages
102
Found the error in start Sub

Sub VisForm() ' Show form
If ActiveCell.Column <> 2 Then Exit Sub
UserForm1.Show
' *** Next line is the problem ***
UserForm1.ListBox1.ListIndex = 22
End Sub

my bad sorry

but thanks for ur time/replies Andrew
 

Watch MrExcel Video

Forum statistics

Threads
1,129,871
Messages
5,638,773
Members
417,052
Latest member
Noobest

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
Top