Re: Userform dynamisch erzeugen
19.07.2002 19:58:54
Bernd
Hallo Frank,schau Dir mal das untenstehende Listing an. Es funktioniert für zweispaltige Daten auf dem Tabellenblatt "Projekte" ab Zeile 2. Du brauchst ein Userform mit einer Combobox mit ColumnCount=2. Bei Userform1.Show wird unten stehender VBA-Code ausgeführt und die Daten der Combobox werden befüllt. Die letzte Zeile wählt dann eine Zeile aus.
Ciao
der Bernd
Private Sub UserForm_Initialize()
Dim intI%, intJ%
Dim strProj$
Dim arrDaten() As String
Dim strTmp$, strZeile$
intI = 2
With ThisWorkbook.Worksheets("Projekte")
While .Cells(intI, 1) <> ""
intI = intI + 1
Wend
intI = intI - 1
ReDim arrDaten(1 To intI - 1, 1)
For intJ = 2 To intI
arrDaten(intJ - 1, 0) = .Cells(intJ, 1).Text
arrDaten(intJ - 1, 1) = .Cells(intJ, 2).Text
Next intJ
End With
Me.ComboBox1.List() = arrDaten
Me.ComboBox1.Value = "Test"
End Sub