AW: Listbox
27.05.2008 10:04:00
Dirk
Hallo Ernst,
wenn Du ein Userform anlegst hast Du normalerweise Eingabefelder, listboxen etc.
Bei Aufruf der Userform hast Du den notwendigen Code zur vorbelegung der Felder. Dort gehoert auch dieser Code hin.
hier mal mein gesamter code im Initialize:
Private Sub UserForm_Initialize()
Set wsActive = ActiveSheet
CancelButton = 0
'Clear controls for next entry and set default box
'TextShares.Value = ""
'TextPrice.Text = ""
'Populate text boxes with data from the spreadsheet
With CBRegion
.AddItem "APAC"
.AddItem "China"
.AddItem "MEA"
.AddItem "NE"
.AddItem "NA"
.AddItem "SA"
.AddItem "SWE"
End With
CBRegion.Value = Worksheets("reportGenerator").Range("a6").Value
'Set the Report input file/default
If Range("ReportGenerator!A2").Value = "" Then
TxtReportPath.Text = Range("ReportGenerator!A4").Value
Else
TxtReportPath.Text = Range("ReportGenerator!A2").Value
End If
'Set the Report store path/default
If Range("ReportGenerator!A3").Value = "" Then
TxtStorePath.Text = Range("ReportGenerator!A4").Value
Else
TxtStorePath.Text = Range("ReportGenerator!A3").Value
End If
'Set the Report template file
If Range("ReportGenerator!A5").Value = "" Then
TxtRepTemplate.Text = Range("ReportGenerator!A4").Value
Else
TxtRepTemplate.Text = Range("ReportGenerator!A5").Value
End If
'Set the reporting period (as actual month)
TxtRepperiod.Text = CStr(Month(Date))
TxtReportPath.SetFocus
End Sub
Anbei noch ein Screenprint des Userforms:

Ich hoffe das hilft Dir weiter.
Gruss
Dirk aus Dubai