Live-Forum - Die aktuellen Beiträge
Anzeige
Archiv - Navigation
1180to1184
Aktuelles Verzeichnis
Verzeichnis Index
Übersicht Verzeichnisse
Vorheriger Thread
Rückwärts Blättern
Nächster Thread
Vorwärts blättern
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
Inhaltsverzeichnis

Userform und Optionsfeld

Userform und Optionsfeld
Fredy
Hallo alle
Ich möchte gerne auf meinem Userform das tabellenblatt mit Hilfe einer Optionsfeld aus wellen können in dem die eingegebene Daten eingetragen werben Solen
Gruss Fredy
https://www.herber.de/bbs/user/71778.xlsm

10
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Benutzer
Anzeige
AW: Userform und Optionsfeld
07.10.2010 13:33:53
Beverly
Hi Fredy,
Private Sub OptionButton4_Click()
Worksheets("Altpapier").Activate
End Sub
Private Sub OptionButton5_Click()
Worksheets("Zellstoff").Activate
End Sub



AW: Userform und Optionsfeld
07.10.2010 14:00:06
Fredy
Cool ist schon mal ein Anfang aber es sollte kompatibel mit dem bestehende code sein
Private Sub CommandButton1_Click()
Dim Zelle As Long
Dim i As Long
Dim leer As Long
Dim Zeile As Long
With Worksheets("Altpapier")
i = .Range("B:B").Find(what:=ComboBox1.Value).Row
For leer = i To 200000
If .Cells(i, 2) = "" Then
'Zelle = .Cells(Rows.Count, 2).End(xlUp).Row + 1
.Rows(i).Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
.Cells(i, 2) = TextBox1
.Cells(i, 3) = ComboBox1
.Cells(i, 4) = fncSchicht
.Cells(i, 5) = TextBox4
.Cells(i, 6) = TextBox5
.Cells(i, 7) = TextBox6
.Cells(i, 8) = TextBox7
.Cells(i, 9) = TextBox8
.Cells(i, 10) = TextBox9
.Cells(i, 11) = TextBox10
.Cells(i, 12) = TextBox11
.Cells(i, 13) = TextBox12
.Cells(i, 14) = TextBox13
.Cells(i, 15) = TextBox14
.Cells(i, 16) = TextBox15
.Cells(i, 17) = TextBox16
.Cells(i, 18) = TextBox17
.Cells(i, 19) = TextBox18
.Cells(i, 20) = TextBox19
.Cells(i, 21) = TextBox20
.Cells(i, 22) = TextBox21
.Cells(i, 23) = TextBox22
.Cells(i, 24) = TextBox23
.Cells(i, 25) = TextBox24
.Cells(i, 26) = TextBox25
.Cells(i, 27) = TextBox26
.Cells(i, 28) = TextBox27
GoTo liste
Exit Sub
End If
i = i + 1
Next
End With
GoTo liste
liste:
For Zeile = 3 To Worksheets("Altpapier").Cells(Rows.Count, 2).End(xlUp).Row
Worksheets("Altpapier").Cells(Zeile, 1) = Worksheets("Altpapier").Cells(Zeile, 1).Row - 2
Next
End Sub

Private Sub CommandButton2_Click()
Checkliste.Hide
End Sub
Private Sub CommandButton3_Click()
Dim Tb As Integer
On Error Resume Next
For Tb = 4 To 27
Me.Controls("TextBox" & Tb) = ""
Next Tb
End Sub
Private Sub UserForm_Initialize()
Dim rngSorte As Range
Set wksCombo = Worksheets("Combobox")
With wksCombo
Set rngSorte = .Range(.Cells(2, 1), .Cells(.Rows.Count, 1).End(xlUp).Offset(0, 1))
Zeile1 = rngSorte.Row
Me.ComboBox1.RowSource = "'" & .Name & "'!" & rngSorte.Address
End With
With Me.ComboBox1
.ColumnCount = 2
.ListWidth = 200
.ColumnWidths = "50Pt;140Pt"
End With
TextBox1 = Date
End Sub
Private Function fncSchicht()
Dim bytSchicht As Byte
Dim arrSchicht
arrSchicht = Array("nichts gewählt", "Früh", "Mittag", "Nacht")
bytSchicht = -OptionButton1 - 2 * OptionButton2 - 3 * OptionButton3
fncSchicht = arrSchicht(bytSchicht)
End Function

Anzeige
AW: Userform und Optionsfeld
07.10.2010 14:02:17
Fredy
Cool ist schon mal ein Anfang aber es sollte kompatibel mit dem bestehende code sein
Private Sub CommandButton1_Click()
Dim Zelle As Long
Dim i As Long
Dim leer As Long
Dim Zeile As Long
With Worksheets("Altpapier")
i = .Range("B:B").Find(what:=ComboBox1.Value).Row
For leer = i To 200000
If .Cells(i, 2) = "" Then
'Zelle = .Cells(Rows.Count, 2).End(xlUp).Row + 1
.Rows(i).Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
.Cells(i, 2) = TextBox1
.Cells(i, 3) = ComboBox1
.Cells(i, 4) = fncSchicht
.Cells(i, 5) = TextBox4
.Cells(i, 6) = TextBox5
.Cells(i, 7) = TextBox6
.Cells(i, 8) = TextBox7
.Cells(i, 9) = TextBox8
.Cells(i, 10) = TextBox9
.Cells(i, 11) = TextBox10
.Cells(i, 12) = TextBox11
.Cells(i, 13) = TextBox12
.Cells(i, 14) = TextBox13
.Cells(i, 15) = TextBox14
.Cells(i, 16) = TextBox15
.Cells(i, 17) = TextBox16
.Cells(i, 18) = TextBox17
.Cells(i, 19) = TextBox18
.Cells(i, 20) = TextBox19
.Cells(i, 21) = TextBox20
.Cells(i, 22) = TextBox21
.Cells(i, 23) = TextBox22
.Cells(i, 24) = TextBox23
.Cells(i, 25) = TextBox24
.Cells(i, 26) = TextBox25
.Cells(i, 27) = TextBox26
.Cells(i, 28) = TextBox27
GoTo liste
Exit Sub
End If
i = i + 1
Next
End With
GoTo liste
liste:
For Zeile = 3 To Worksheets("Altpapier").Cells(Rows.Count, 2).End(xlUp).Row
Worksheets("Altpapier").Cells(Zeile, 1) = Worksheets("Altpapier").Cells(Zeile, 1).Row - 2
Next
End Sub
Private Sub CommandButton2_Click()
Checkliste.Hide
End Sub

Private Sub CommandButton3_Click()
Dim Tb As Integer
On Error Resume Next
For Tb = 4 To 27
Me.Controls("TextBox" & Tb) = ""
Next Tb
End Sub

Private Sub UserForm_Initialize()
Dim rngSorte As Range
Set wksCombo = Worksheets("Combobox")
With wksCombo
Set rngSorte = .Range(.Cells(2, 1), .Cells(.Rows.Count, 1).End(xlUp).Offset(0, 1))
Zeile1 = rngSorte.Row
Me.ComboBox1.RowSource = "'" & .Name & "'!" & rngSorte.Address
End With
With Me.ComboBox1
.ColumnCount = 2
.ListWidth = 200
.ColumnWidths = "50Pt;140Pt"
End With
TextBox1 = Date
End Sub

Private Function fncSchicht()
Dim bytSchicht As Byte
Dim arrSchicht
arrSchicht = Array("nichts gewählt", "Früh", "Mittag", "Nacht")
bytSchicht = -OptionButton1 - 2 * OptionButton2 - 3 * OptionButton3
fncSchicht = arrSchicht(bytSchicht)
End Function

Anzeige
AW: Userform und Optionsfeld
07.10.2010 17:35:26
Beverly
Hi Fredy,
du musst nur in deinem Code an allen Stellen wo Worksheets("Altpapier") steht schreiben ActiveSheet - dann wird je nach dem, welches Optionsfeld aktiviert und damit das betreffende Tabellenblatt aktiv ist, sich auf dieses bezogen.


AW: Userform und Optionsfeld
07.10.2010 18:30:55
Fredy
So meinst du oder
With Worksheets("ActiveSheet")
AW: Userform und Optionsfeld
07.10.2010 18:40:38
Beverly
Hi Fredy,
ich meine das, was ich geschrieben habe. Der Name in Klammern und Anführungszeichen ist der Name, der auf dem Tabellenreiter steht.


Anzeige
AW: Userform und Optionsfeld
07.10.2010 18:50:43
Fredy
Ok habe ich gemacht geht aber immer noch nicht sorry
Immer wenn ich es ausführe kommt eine neue Meldung
Index außerhalb des gültigen Bereich und im code ist
With Worksheets("ActiveSheet") gelb markiert
Private Sub CommandButton1_Click()
Dim Zelle As Long
Dim i As Long
Dim leer As Long
Dim Zeile As Long
With Worksheets("ActiveSheet")
i = .Range("B:B").Find(what:=ComboBox1.Value).Row
For leer = i To 200000
If .Cells(i, 2) = "" Then
'Zelle = .Cells(Rows.Count, 2).End(xlUp).Row + 1
.Rows(i).Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
.Cells(i, 2) = TextBox1
.Cells(i, 3) = ComboBox1
.Cells(i, 4) = fncSchicht
.Cells(i, 5) = TextBox4
.Cells(i, 6) = TextBox5
.Cells(i, 7) = TextBox6
.Cells(i, 8) = TextBox7
.Cells(i, 9) = TextBox8
.Cells(i, 10) = TextBox9
.Cells(i, 11) = TextBox10
.Cells(i, 12) = TextBox11
.Cells(i, 13) = TextBox12
.Cells(i, 14) = TextBox13
.Cells(i, 15) = TextBox14
.Cells(i, 16) = TextBox15
.Cells(i, 17) = TextBox16
.Cells(i, 18) = TextBox17
.Cells(i, 19) = TextBox18
.Cells(i, 20) = TextBox19
.Cells(i, 21) = TextBox20
.Cells(i, 22) = TextBox21
.Cells(i, 23) = TextBox22
.Cells(i, 24) = TextBox23
.Cells(i, 25) = TextBox24
.Cells(i, 26) = TextBox25
.Cells(i, 27) = TextBox26
.Cells(i, 28) = TextBox27
GoTo liste
Exit Sub
End If
i = i + 1
Next
End With
GoTo liste
liste:
For Zeile = 3 To Worksheets("ActiveSheet").Cells(Rows.Count, 2).End(xlUp).Row
Worksheets("ActiveSheet").Cells(Zeile, 1) = Worksheets("ActiveSheet").Cells(Zeile, 1).Row - 2
Next
End Sub

Private Sub CommandButton2_Click()
Checkliste.Hide
End Sub
Private Sub CommandButton3_Click()
Dim Tb As Integer
On Error Resume Next
For Tb = 4 To 27
Me.Controls("TextBox" & Tb) = ""
Next Tb
End Sub
Private Sub UserForm_Initialize()
Dim rngSorte As Range
Set wksCombo = Worksheets("Combobox")
With wksCombo
Set rngSorte = .Range(.Cells(2, 1), .Cells(.Rows.Count, 1).End(xlUp).Offset(0, 1))
Zeile1 = rngSorte.Row
Me.ComboBox1.RowSource = "'" & .Name & "'!" & rngSorte.Address
End With
With Me.ComboBox1
.ColumnCount = 2
.ListWidth = 200
.ColumnWidths = "50Pt;140Pt"
End With
TextBox1 = Date
End Sub
Private Function fncSchicht()
Dim bytSchicht As Byte
Dim arrSchicht
arrSchicht = Array("nichts gewählt", "Früh", "Mittag", "Nacht")
bytSchicht = -OptionButton1 - 2 * OptionButton2 - 3 * OptionButton3
fncSchicht = arrSchicht(bytSchicht)
End Function

Private Sub OptionButton4_Click()
Worksheets("Altpapier").Activate
End Sub

Private Sub OptionButton5_Click()
Worksheets("Zellstoff").Activate
End Sub

Anzeige
AW: Userform und Optionsfeld
07.10.2010 19:19:08
robert
Hi,
lies noch einmal langsam und genau, was Beverly geschrieben hat.
statt Worksheets("Altpapier"), ActiveSheet
gruß
robert
AW: Userform und Optionsfeld
07.10.2010 19:32:32
Fredy
Ok sorry dann las ich halb bin halb ne niete sorry für die Störung
AW: Userform und Optionsfeld
09.10.2010 12:01:46
Fredy
.

Links zu Excel-Dialogen

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige