VBA Do While...Loop

Viewed 46

I am learning VBA now and have a little problem with a code.

When clicking the button, the program should read the values from the first column until an empty row appears and show them in a Label. This action must be executed only once, that means, the values must not be repeated. Also, if the first cell is already empty, the program must show a message in the Label telling the user, that there are no values to be read. Previously read values must not be shown anymore.

This is my code:

Private Sub btn_Werte_einlesen_Click()
Dim znr As Long
znr = 1
Do While Range("A" & znr) <> ""
    
    lbl_Anzeige = lbl_Anzeige & Range("A" & znr) & vbLf
   
    znr = znr + 1
Loop
End Sub

I would appreciate any help.

Thanks a lot!

0 Answers
Related