19.06.2019, 09:06 (Dieser Beitrag wurde zuletzt bearbeitet: 19.06.2019, 09:07 von Steffl.
Bearbeitungsgrund: PS eingefügt
)
Hallo,
vielleicht so
Code:
Private Sub UserForm_Initialize()
Dim i As Integer Dim j As Integer
For k = 1 To ThisWorkbook.Worksheets("Tabelle1").Cells(1, Cells.Columns.Count).End(xlToLeft).Column ListBox_Muskelgruppe.AddItem ThisWorkbook.Worksheets("Tabelle1").Cells(1, k) Next
'KW
With ComboBox_KW For i = 1 To 52 .AddItem CInt(i) .Value = DatePart("ww", Date, vbMonday, vbFirstFourDays) 'von Nepumuk Next End With 'DatePart("ww", dein-datum , vbMonday, vbFirstFourDays)' 'Me.
'Wochentag With ListBox_Wochentag .AddItem "Montag" .AddItem "Dienstag" .AddItem "Mittwoch" .AddItem "Donnerstag" .AddItem "Freitag" .AddItem "Samstag" .AddItem "Sonntag" .ListIndex = (DatePart("w", Date, vbMonday, vbFirstFourDays) - 1) End With
'Training With ListBox_Training .AddItem "Muskelaufbau" .AddItem "Cardio" End With
und wie das immer so ist, wenn man dabei ist kommen einem neue Ideen. Ich lasse das Datum aus Jahr, KW und Wochentag in der Exceltabelle errechnen. Nun würde ich das auch gern in VBA machen und dann direct übergeben.
Ich habe folgendes probiert:
Code:
Private Sub Button_Eingabe_Click()
'Erste freie Zeile ausfindig machen Dim last As Integer last = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row + 1
'Satz If OptionButton_Satz1.Value = True Then Cells(last, 7).Value = "Satz 1" If OptionButton_Satz2.Value = True Then Cells(last, 7).Value = "Satz 2" If OptionButton_Satz3.Value = True Then Cells(last, 7).Value = "Satz 3" If OptionButton_Satz4.Value = True Then Cells(last, 7).Value = "Satz 4"
'Gewicht If ListBox_Training = "Cardio" Then Cells(last, 8).Value = "" If ListBox_Training = "Muskelaufbau" Then Cells(last, 8).Value = TextBox_Gewicht
'Wiederholung If ListBox_Training = "Cardio" Then Cells(last, 9).Value = "" If ListBox_Training = "Muskelaufbau" Then Cells(last, 9).Value = TextBox_Wdhlg
'Intervall If OptionButton_Interv1.Value = True Then Cells(last, 10).Value = "Intervall 1" If OptionButton_Interv2.Value = True Then Cells(last, 10).Value = "Intervall 2" If OptionButton_Interv3.Value = True Then Cells(last, 10).Value = "Intervall 3" If OptionButton_Interv4.Value = True Then Cells(last, 10).Value = "Intervall 4" If OptionButton_Interv5.Value = True Then Cells(last, 10).Value = "Intervall 5" If OptionButton_Interv6.Value = True Then Cells(last, 10).Value = "Intervall 6"
'Strecke Cells(last, 11).Value = TextBox_Strecke
'Zeit If ListBox_Training = "Cardio" Then Cells(last, 12).Value = TextBox_Zeit If ListBox_Training = "Muskelaufbau" Then Cells(last, 12).Value = ""
wenn Du es als Formel eintragen willst, kannst Du es mal so versuchen, wobei ich mir nicht sicher bin, ob die Anführungszeichen richtig eingetragen werden.
ob die Formel wirklich so paßt, weiß ich nicht zumindest ist von mir angesprochene Fehler weg. Außerdem habe ich in zwei Fällen dafür gesorgt, dass Zahlen auch tatsächlich als Zahlen eingetragen werden.
Code:
Private Sub Button_Eingabe_Click()
'Erste freie Zeile ausfindig machen Dim last As Integer Dim intZaehler As Integer
last = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row + 1
'Satz If OptionButton_Satz1.Value = True Then Cells(last, 7).Value = "Satz 1" If OptionButton_Satz2.Value = True Then Cells(last, 7).Value = "Satz 2" If OptionButton_Satz3.Value = True Then Cells(last, 7).Value = "Satz 3" If OptionButton_Satz4.Value = True Then Cells(last, 7).Value = "Satz 4"
'Gewicht If ListBox_Training = "Cardio" Then Cells(last, 8).Value = "" If ListBox_Training = "Muskelaufbau" Then Cells(last, 8).Value = TextBox_Gewicht
'Wiederholung If ListBox_Training = "Cardio" Then Cells(last, 9).Value = "" If ListBox_Training = "Muskelaufbau" Then Cells(last, 9).Value = TextBox_Wdhlg
'Intervall For intZaehler = 1 To 6 If Controls("OptionButton_Interv" & intZaehler) Then Cells(last, 10).Value = "Intervall " & intZaehler: Exit For Next intZaehler 'If OptionButton_Interv1.Value = True Then Cells(last, 10).Value = "Intervall 1" 'If OptionButton_Interv2.Value = True Then Cells(last, 10).Value = "Intervall 2" 'If OptionButton_Interv3.Value = True Then Cells(last, 10).Value = "Intervall 3" 'If OptionButton_Interv4.Value = True Then Cells(last, 10).Value = "Intervall 4" 'If OptionButton_Interv5.Value = True Then Cells(last, 10).Value = "Intervall 5" 'If OptionButton_Interv6.Value = True Then Cells(last, 10).Value = "Intervall 6"
'Strecke Cells(last, 11).Value = TextBox_Strecke
'Zeit If ListBox_Training = "Cardio" Then Cells(last, 12).Value = TextBox_Zeit If ListBox_Training = "Muskelaufbau" Then Cells(last, 12).Value = ""