Link to home
Create AccountLog in
Avatar of Massimo Scola
Massimo ScolaFlag for Switzerland

asked on

How do I refill a userform listbox after a new entry has been added?

This question may have been asked a few times - but I could not find an answer online.

I have created a userform which displays the customer's name and other information. I can successfully amend the data and write it back to the spreadsheet. I've also written a procedure that sorts the name of the customer: It's a named range.

I wish that the listbox is refilled again - without having to close the userform - in such a way that the customer name is sorted from A to Z.

Thanks for your help.

This is the code which is executed when the information is saved to the spreadsheet. What next?
 
Private Sub btnÄndern_Click()
    
   With Range("Kunden_mit_Adresse").Cells(lstKundenListe.ListIndex + 1, 1)
        .Offset(, 0) = cmbAnrede.Value
        .Offset(, 1) = txtKundenName.Value
        .Offset(, 2) = txtAdresse.Value
        .Offset(, 3) = txtStrassenNummer.Value
        .Offset(, 4) = txtPLZ.Value
        .Offset(, 5) = txtOrt.Value
        .Offset(, 6) = txtTelefonPrivat.Value
        .Offset(, 7) = txtTelefonGeschäft.Value
    End With


End Sub

Open in new window

userform.xlsm
Avatar of Rory Archibald
Rory Archibald
Flag of United Kingdom of Great Britain and Northern Ireland image

Add:
lbTarget.List = rngSourceKunde.Cells.Value

to the end of that procedure.
Avatar of Massimo Scola

ASKER

Hi rorya

I've added it at the end of the procedure, but I get an error message. The rngSourceKunde is not a variable. Am I missing something?
ASKER CERTIFIED SOLUTION
Avatar of Rory Archibald
Rory Archibald
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
thanks a lot - it worked
sorry for the late "thank you"