Verständnisfrage
RainerK
habe für eine UserForm folgende Initialisierung.
Private Sub UserForm_Initialize()
Dim IntS As Integer
Dim wks As Worksheet
Set wks = Worksheets("BS")
With ListBox1
.Font.Size = 9
.ForeColor = RGB(0, 0, 255)
.ColumnCount = 11
.ColumnWidths = ("4,6cm;3,3cm;2,9cm;0;0;1,8cm;2,8cm;0;0;2cm;1cm")
.Clear
For IntS = 7 To wks.Range("IV4").End(xlToLeft).Column
If Cells(13, IntS) > "" Then
.AddItem wks.Cells(4, IntS) & " " & wks.Cells(5, IntS)
'.List(.ListCount - 1, 1) = wks.Cells(5, IntS)
.List(.ListCount - 1, 1) = wks.Cells(9, IntS)
.List(.ListCount - 1, 2) = Format(wks.Cells(21, IntS), "#,##0.00")
.List(.ListCount - 1, 3) = Format(wks.Cells(23, IntS), "#,##0.00")
.List(.ListCount - 1, 4) = Format(wks.Cells(25, IntS), "#,##0.00")
.List(.ListCount - 1, 5) = Format(wks.Cells(26, IntS), "#,##0.00")
.List(.ListCount - 1, 6) = Format(wks.Cells(32, IntS), "#,##0.00")
.List(.ListCount - 1, 7) = Format(wks.Cells(33, IntS), "#,##0.00")
.List(.ListCount - 1, 8) = Format(wks.Cells(34, IntS), "#,##0.00")
.List(.ListCount - 1, 9) = Format(wks.Cells(35, IntS), "#,##0.00") & " "
End If
Next IntS
End With
End Sub
Mit Set wks müsste die UserForm doch von jedem beliebigen Tabellenblatt aus aufgerufen werden können oder habe ich irgendwo noch ein "wks" vergessen?Leider klappt der Aufruf nur, wenn ich im Arbeitsblatt "BS" bin.
Gruß Rainer