erik.van.geit
MrExcel MVP
- Joined
- Feb 1, 2003
- Messages
- 17,832
Hi,
Happy New Year!
The following occured within a file and I can replicate this error in new files.
I created a userform with 2 listboxes and a button.
Then pasted this code
Put a number between 2 and 7 in A1 and A2.
Run the userform.
When clicking the button: cell A2 get's empty value.
EDIT: forgot to mention: this only occurs when you do not click within ListBox2 before you hit the button. When you choose another value within ListBox2, you get the correct value in A2.
You can try this out in 1 minute: do you get this too???
kind regards,
Erik
EDIT: sometimes only occurs when you show the userform the second time
Happy New Year!
The following occured within a file and I can replicate this error in new files.
I created a userform with 2 listboxes and a button.
Then pasted this code
Code:
Private Sub CommandButton1_Click()
Range("A1") = ListBox1
Range("A2") = ListBox2
End Sub
Private Sub UserForm_Initialize()
ListBox1.List = Array(2, 3, 4, 5, 6, 7)
ListBox2.List = Array(2, 3, 4, 5, 6, 7)
With ListBox1
.ListIndex = Application.Match(Range("A1"), .List, 0) - 1
End With
With ListBox2
.ListIndex = Application.Match(Range("A2"), .List, 0) - 1
End With
End Sub
Run the userform.
When clicking the button: cell A2 get's empty value.
EDIT: forgot to mention: this only occurs when you do not click within ListBox2 before you hit the button. When you choose another value within ListBox2, you get the correct value in A2.
You can try this out in 1 minute: do you get this too???
kind regards,
Erik
EDIT: sometimes only occurs when you show the userform the second time
Last edited: