I make use of a listbox on a worksheet.
The user can select an item from the listbox, hit a button and an userform shows up.
On the userform the user can amend the corresponding items hit and the save button.
After pressing the save button the selected item is still the focus of the listbox.
This makes it possible for the user to hit a "previous" or "next" button, which will set the focus to the previous or next item.
However, In some cases, while amending data on the userform, new data may be added from a second userform.
The problem is that after the save-button is presssed on the second userform the focus on the listbox is lost.
This while the data of the selected item from the listbox is still shown on the userform, which is still open.
Is there a way that after hitting the save-button on the sub-userform the focus is brought back?
This is the code,on the sub-userform, after which the listbox looses focus.
- Private Sub cmbAdd_Click()
- Set c = Sheets("Posten").Range("A65536").End(xlUp).Offset(1, 0)
- Application.ScreenUpdating = False
- With Me
- c.Value = .TextBox1.Value
- c.Offset(0, 1).Value = .TextBox2.Value
- End With
- Application.ScreenUpdating = True
- End Sub