Microsoft Excel

Herbers Excel/VBA-Archiv

Informationen und Beispiele zum Thema CommandButton
BildScreenshot zu CommandButton CommandButton-Seite mit Beispielarbeitsmappe aufrufen

Combo Box VBA

Betrifft: Combo Box VBA von: Marc
Geschrieben am: 04.11.2014 07:07:19

Hello,

please see attached uploaded file.

I try to chose some Input data from the Combo box and list those under each other. So first I chose A and click on the Add button. This should go to D1. After that I chose B and it should go under D2. And so on....

Thanks for help!!

Marc

https://www.herber.de/bbs/user/93527.xlsx

  

Betrifft: AW: Combo Box VBA von: Rudi Maintaire
Geschrieben am: 04.11.2014 09:30:24

Hallo,

Private Sub CommandButton1_Click()
  Dim lRow As Long
  lRow = Cells(Rows.Count, 4).End(xlUp).Row
  If lRow > 1 Then lRow = lRow + 1
  Cells(lRow, 4) = ComboBox1
End Sub
Gruß
Rudi


  

Betrifft: AW: Combo Box VBA von: Marc
Geschrieben am: 04.11.2014 16:35:38

Hi Rudi,

thanks a lot. Right now it always replace D1 when I chose a new item from the list. Is it possible that it will add up to the cells D2, D3 etc. ? So I can create another list out of my original list.

Thanks

Marc


  

Betrifft: AW: Combo Box VBA von: Uduuh
Geschrieben am: 05.11.2014 19:12:14

Hello,
sorry for the mistake.

Private Sub CommandButton1_Click()
  Dim lRow As Long
  lRow = Cells(Rows.Count, 4).End(xlUp).Row
  If Cells(lRow, 4) <> "" Then lRow = lRow + 1
  Cells(lRow, 4) = ComboBox1
End Sub
Gruß
Rudi