Avatar of Massimo Scola
Massimo Scola
Flag 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

Microsoft ExcelVisual Basic Classic

Avatar of undefined
Last Comment
Massimo Scola

8/22/2022 - Mon
Rory Archibald

lbTarget.List = rngSourceKunde.Cells.Value

to the end of that procedure.
Massimo Scola

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?
Rory Archibald

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Massimo Scola

thanks a lot - it worked
sorry for the late "thank you"
Your help has saved me hundreds of hours of internet surfing.