Hallo Bastrong,
ich habe mich mal versucht.
Eine neue Zeile wird jetzt aus der 2. Zeile des Tabellenblattes Vorlage kopiert.
Bestehende Angebote können einfach mit Doppelklick in eine beliebige Zelle der entsprechenden Zeile bearbeitet werden.
Hier alle benötigten Codes:
' **************************************************************
' Modul: Tabelle1 Typ = Element der Mappe(Sheet, Workbook, ...)
' **************************************************************
Option Explicit
Private Sub CommandButton1_Click() 'Button Zeile+ & Userform
ActiveCell.Activate
Vorlage.Rows(2).Copy
Rows(6).Insert Shift:=xlDown
Rows(6) = ""
Range("A6").Value = Application.Max(Range(Cells(7, 1), Cells(Rows.Count, 1).End(xlUp)).Value) + 1
Application.CutCopyMode = False
Range("A6").Activate
UserForm1.Show
End Sub
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Target.Row > 5 Then
If Len(Cells(Target.Row, 1).Value) Then
UserForm1.Show
End If
End If
End Sub
' **************************************************************
' Modul: UserForm1 Typ = Userform
' **************************************************************
Option Explicit
Private Sub CommandButton2_Click() 'Button "Schließen ohne Änderungen"
Unload Me
End Sub
Private Sub CommandButton4_Click() 'Button "Übernehmen und Schließen"
Dim i As Long, j As Long
Cells(Me.Tag, 2).Value = TextBox2.Text 'Infor
Cells(Me.Tag, 3).Value = TextBox3.Text 'Kunde
Cells(Me.Tag, 4).Value = TextBox4.Text 'Ort
Cells(Me.Tag, 5).Value = TextBox5.Text 'Vertretung
Cells(Me.Tag, 6).Value = TextBox6.Text 'Datum
Cells(Me.Tag, 7).Value = TextBox7.Text 'Anfrage-Datum
Cells(Me.Tag, 32).Value = TextBox8.Text 'Angebotswert
Cells(Me.Tag, 34).Value = TextBox10.Text 'Bemerkung
Cells(Me.Tag, 10).Value = TextBox11.Text 'ID
Cells(Me.Tag, 13).Value = TextBox12.Text 'ID
Cells(Me.Tag, 16).Value = TextBox13.Text 'ID
Cells(Me.Tag, 19).Value = TextBox14.Text 'ID
Cells(Me.Tag, 22).Value = TextBox15.Text 'ID
Cells(Me.Tag, 25).Value = TextBox16.Text 'ID
Cells(Me.Tag, 28).Value = TextBox17.Text 'ID
Cells(Me.Tag, 33).Value = TextBox18.Text 'Bestellwert
With Cells(Me.Tag, 1).Resize(1, 35)
'nur wenn momentaner Wert von ursprünglichem Wert abweicht
If CBool(CheckBox1.Value) <> CheckBox1.Tag Then
If CheckBox1.Value = True Then
.Borders.LineStyle = xlContinuous
.Interior.ColorIndex = 35
.Cells(1, 9).Value = "X"
Else
.Borders.LineStyle = xlNone
.Interior.ColorIndex = xlNone
.Cells(1, 9).Value = ""
End If
End If
End With
j = 1
For i = 10 To 28 Step 3
j = j + 1 'Schleife für CheckBoxen 2 - 8
With Cells(Me.Tag, i).Resize(1, 3)
'nur wenn momentaner Wert von ursprünglichem Wert abweicht
If CBool(Me.Controls("CheckBox" & j).Value) <> Me.Controls("CheckBox" & j).Tag Then
.Borders.LineStyle = xlContinuous
If Me.Controls("CheckBox" & j).Value = True Then
.Interior.ColorIndex = 35
.Cells(1, .Cells.Count).Value = "B"
Else
.Interior.ColorIndex = 38
.Cells(1, .Cells.Count).Value = "O"
End If
End If
End With
Next i
Unload Me
End Sub
Private Sub UserForm_Activate()
Dim i As Long
Me.Tag = ActiveCell.Row 'Zeilennummer der aktiven Zelle wird gespeichert
TextBox1.Enabled = False 'Textbox1 ist schreibgeschützt
TextBox1.Text = Cells(Me.Tag, 1).Value 'Angebots-Nr.
TextBox2.Text = Cells(Me.Tag, 2).Value 'Infor
TextBox3.Text = Cells(Me.Tag, 3).Value 'Kunde
TextBox4.Text = Cells(Me.Tag, 4).Value 'Ort
TextBox5.Text = Cells(Me.Tag, 5).Value 'Vertretung
TextBox6.Text = Cells(Me.Tag, 6).Value 'Datum
TextBox7.Text = Cells(Me.Tag, 7).Value 'Anfrage-Datum
TextBox8.Text = Cells(Me.Tag, 32).Value 'Angebotswert
TextBox10.Text = Cells(Me.Tag, 34).Value 'Bemerkung
TextBox11.Text = Cells(Me.Tag, 10).Value 'ID
TextBox12.Text = Cells(Me.Tag, 13).Value 'ID
TextBox13.Text = Cells(Me.Tag, 16).Value 'ID
TextBox14.Text = Cells(Me.Tag, 19).Value 'ID
TextBox15.Text = Cells(Me.Tag, 22).Value 'ID
TextBox16.Text = Cells(Me.Tag, 25).Value 'ID
TextBox17.Text = Cells(Me.Tag, 28).Value 'ID
TextBox18.Text = Cells(Me.Tag, 33).Value 'Bestellwert
CheckBox1 = Cells(Me.Tag, 9).Value = "X"
CheckBox2 = Cells(Me.Tag, 12).Value = "B"
CheckBox3 = Cells(Me.Tag, 15).Value = "B"
CheckBox4 = Cells(Me.Tag, 18).Value = "B"
CheckBox5 = Cells(Me.Tag, 21).Value = "B"
CheckBox6 = Cells(Me.Tag, 24).Value = "B"
CheckBox7 = Cells(Me.Tag, 27).Value = "B"
CheckBox8 = Cells(Me.Tag, 30).Value = "B"
'Momentane CheckBoxwerte werden im jeweiligen Tag der Checkboxen gespeichert
For i = 1 To 8
Me.Controls("CheckBox" & i).Tag = CBool(Me.Controls("CheckBox" & i).Value)
Next i
End Sub
Code eingefügt mit: Excel Code Jeanie
Hier die Beispieldateien (mit und ohne VBA):
Mausklick auf Zeile + Userform + Automatisch Werte aus Zeile ziehen_Kuwer.xls (Größe: 70,5 KB / Downloads: 4)
Mausklick auf Zeile + Userform + Automatisch Werte aus Zeile ziehen_Kuwer.xlsx (Größe: 15,6 KB / Downloads: 5)
Gruß Uwe