AW: Wert aus Excel in Word Formular
21.01.2005 08:42:46
klaus
Hallo,
hier der code für zum eintragen der Werte aus der userForm in die Excel- Tabelle.
Der Code wurde von mir aus anderen, bestehenden Codes zusammengestellt da ich kein Profi im Makroschreiben bin.
Private Sub cmdEintragen_Click()
Dim i As Byte, control As Boolean
Dim lgFreieZeile As Integer
Worksheets("Berichte").Unprotect Password:="EP"
Application.ScreenUpdating = False
' Eintrag von Ausgelöst durch
If ComboBox1.Text <> "" Then
If ComboBox1.ListCount > 0 Then
For i = 0 To ComboBox1.ListCount - 1
If ComboBox1.List(i) = ComboBox1.Text Then control = True
Next i
If control Then
Worksheets("Berichte").Activate
lgFreieZeile = [B65536].End(xlUp).Row + 1
Worksheets("Berichte").Cells(lgFreieZeile, 9) = Controls("ComboBox1").Value
Else
Worksheets("Tabelle1").Activate
lgFreieZeile = [C65536].End(xlUp).Row + 1
Worksheets("Tabelle1").Cells(lgFreieZeile, 3) = Controls("ComboBox1").Value
Worksheets("Berichte").Activate
lgFreieZeile = [B65536].End(xlUp).Row + 1
Worksheets("Berichte").Cells(lgFreieZeile, 9) = Controls("ComboBox1").Value
End If
End If
End If
'Eintrag von Lieferant
If ComboBox2.Text <> "" Then
If ComboBox2.ListCount > 0 Then
For i = 0 To ComboBox2.ListCount - 1
If ComboBox2.List(i) = ComboBox2.Text Then control = True
Next i
If control Then
Worksheets("Berichte").Activate
lgFreieZeile = [B65536].End(xlUp).Row + 1
Worksheets("Berichte").Cells(lgFreieZeile, 5) = Controls("ComboBox2").Value
Else
Worksheets("Tabelle1").Activate
lgFreieZeile = [B65536].End(xlUp).Row + 1
Worksheets("Tabelle1").Cells(lgFreieZeile, 2) = Controls("ComboBox2").Value
Worksheets("Berichte").Activate
lgFreieZeile = [B65536].End(xlUp).Row + 1
Worksheets("Berichte").Cells(lgFreieZeile, 5) = Controls("ComboBox2").Value
End If
'Else
'Worksheets("Berichte").Activate
'lgFreieZeile = [i65536].End(xlUp).Row + 1
'Worksheets("Berichte").Cells(lgFreieZeile, 5) = ComboBox2.Value
'Worksheets("Tabelle1").Activate
'lgFreieZeile = [i65536].End(xlUp).Row + 1
'Worksheets("Tabelle1").Cells(lgFreieZeile, 5) = ComboBox2.Value
'End If
End If
Worksheets("Berichte").Activate
lgFreieZeile = [B65536].End(xlUp).Row + 1
Worksheets("Berichte").Cells(lgFreieZeile, 4) = txbDat.Value
Worksheets("Berichte").Cells(lgFreieZeile, 12) = TextBox2.Value
Worksheets("Berichte").Cells(lgFreieZeile, 13) = TextBox3.Value
Worksheets("Berichte").Cells(lgFreieZeile, 14) = TextBox4.Value
Worksheets("Berichte").Cells(lgFreieZeile, 15) = TextBox5.Value
Worksheets("Berichte").Cells(lgFreieZeile, 6) = TextBox6.Value
Worksheets("Berichte").Cells(lgFreieZeile, 7) = TextBox7.Value
Worksheets("Berichte").Cells(lgFreieZeile, 8) = TextBox8.Value
Worksheets("Berichte").Cells(lgFreieZeile, 11) = txbUser.Value
Worksheets("Berichte").Cells(lgFreieZeile, 1) = TextBox13.Value
Worksheets("Berichte").Cells(lgFreieZeile, 10) = TextBox10.Value
Worksheets("Berichte").Cells(lgFreieZeile, 16) = TextBox12.Value
lgFreieZeile = Worksheets("Berichte").Range("B65536").End(xlUp).Row + 1
Cells(lgFreieZeile, 2) = Cells(lgFreieZeile - 1, 2) + 1
Call ExportForm
Range("A1").Select
Worksheets("Berichte").Protect Password:="EP", DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowInsertingHyperlinks:=True, AllowFiltering:=True
TextBox2 = ""
TextBox3 = ""
TextBox4 = ""
TextBox5 = ""
TextBox6 = ""
TextBox7 = ""
TextBox8 = ""
TextBox10 = ""
TextBox12 = ""
Call numaktual
Application.ScreenUpdating = True
End If
End Sub