AW: Lade deine Datei mit dem UF hoch! o.T.
01.06.2019 14:12:23
Sepp
Hallo Max,
Dialog UF
Option Explicit
Private Sub Userform_Initialize()
With ComboBox_combo1
.AddItem "a"
.AddItem "b"
.AddItem "c"
End With
With ComboBox_combo2
.AddItem "d"
.AddItem "e"
End With
With Combobox_combo3
.AddItem "f"
.AddItem "g"
End With
With ComboBox_combo4
.AddItem "h"
.AddItem "i"
End With
With ComboBox_combo5
.AddItem "j"
.AddItem "k"
.AddItem "l"
.AddItem "m"
.AddItem "n"
End With
With ComboBox_combo6
.AddItem "0"
.AddItem "p"
.AddItem "q"
End With
ListBox_list1.ListStyle = fmListStyleOption
ListBox_list1.MultiSelect = fmMultiSelectMulti
With ListBox_list1
.AddItem "r"
.AddItem "s"
.AddItem "t"
.AddItem "u"
.AddItem "v"
.AddItem "w"
.AddItem "x"
.AddItem "y"
.AddItem "z"
.AddItem "aa"
.AddItem "bb"
End With
ListBox_list2.ListStyle = fmListStyleOption
ListBox_list2.MultiSelect = fmMultiSelectMulti
With ListBox_list2
.AddItem "cc"
.AddItem "dd"
.AddItem "ee"
.AddItem "ff"
End With
ListBox_list3.ListStyle = fmListStyleOption
ListBox_list3.MultiSelect = fmMultiSelectMulti
With ListBox_list3
.AddItem "gg"
.AddItem "hh"
.AddItem "ii"
.AddItem "jj"
.AddItem "kk"
.AddItem "ll"
.AddItem "mm"
.AddItem "nn"
.AddItem "oo"
.AddItem "pp"
.AddItem "qq"
.AddItem "rr"
.AddItem "ss"
.AddItem "tt"
.AddItem "uu"
.AddItem "vv"
.AddItem "ww"
.AddItem "xx"
End With
End Sub
Private Sub CommandButton_Abbrechen_Click()
Unload Me
End Sub
Private Sub CommandButton_Eingabe_Click()
Dim lngItem As Long, lngLast As Long
lngLast = Cells(Rows.Count, 1).End(xlUp).Row + 1
Cells(lngLast, 1).Value = ComboBox_combo1.Value
Cells(lngLast, 2).Value = TextBox_text1.Value
Cells(lngLast, 3).Value = ComboBox_combo2.Value
Cells(lngLast, 4).Value = TextBox_text2.Value
Cells(lngLast, 5).Value = Combobox_combo3.Value
Cells(lngLast, 6).Value = Textbox_text3.Value
Cells(lngLast, 7).Value = TextBox_text4.Value
Cells(lngLast, 8).Value = TextBox_text5.Value
Cells(lngLast, 9).Value = ComboBox_combo4.Value
Cells(lngLast, 25).Value = ComboBox_combo5.Value
Cells(lngLast, 26).Value = TextBox_text6.Value
Cells(lngLast, 27).Value = TextBox_text7.Value
Cells(lngLast, 43).Value = ComboBox_combo6.Value
Cells(lngLast, 44).Value = TextBox_text8.Value
Cells(lngLast, 45).Value = TextBox_text9.Value
With ListBox_list1
For lngItem = 0 To .ListCount - 1
If .Selected(lngItem) Then Range("J:T").Cells(lngLast, lngItem + 1) = .List(lngItem, 0)
Next
End With
With ListBox_list2
For lngItem = 0 To .ListCount - 1
If .Selected(lngItem) Then Range("U:X").Cells(lngLast, lngItem + 1) = .List(lngItem, 0)
Next
End With
With ListBox_list3
For lngItem = 0 To .ListCount - 1
If .Selected(lngItem) Then Range("AB:AP").Cells(lngLast, lngItem + 1) = .List(lngItem, 0)
Next
End With
End Sub
VBA/HTML-CodeConverter, AddIn für Office 2002-2016 - in VBA geschrieben von Lukas Mosimann. Projektbetreuung:RMH Software & Media
Code erstellt und getestet in Office 16 - mit VBAHTML 12.6.0
Die Leerzeilen in deinem Code stören arg beim Lesen!
Wenn du dich auf die aktive Tabelle beziehst, brauchst du nicht eigens auf diese verweisen.
Bei den Steuerelementen brauchst du im Klassenmodul des UF diese nicht separat Voranstellen.