Änderungen protokollieren

    • VBA: Excel

      Änderungen protokollieren

      Hallo liebe Community,

      Wenn mehrere Anwender (Team) an Excel-Tabellen arbeiten oder Arbeitsmappen der Reihe nach an verschiedene Empfänger (Teammitglieder) verteilt werden, ist es sinnvoll, Änderungen genau zu erfassen und zu protokollieren. Wer hat zu welchem Zeitpunkt welche Zelle verändert?
      Excel bietet Ihnen für diese Aufgabe eine passende Funktion an. Diese Funktion zeichnet Änderungen an Zellen auf.

      Ich möchte heute Ihnen ein VBA-Projekt vorstellen, das ähnliche Funktion wie Excel hat aber die Änderungen durch den Anwender erfasst werden.

      Gehen Sie dazu wie folgt vor:

      1) Starten Sie Excel
      2) Wenn Sie kein Arbeitsblatt sehen. Fügen Sie eine neue Arbeitsmappe ein (Datei--> Neu--> Leere Arbeitsmappe)
      3) Wechseln Sie mit Tastenkombination Alt+F11 zu VBA -Editor
      4) Fügen Sie ein Modul ein (Einfügen--> Modul) Ändern Sie (Name)-Eigenschaft von Modul1 nicht.
      5) Fügen Sie eine Userform ein (Einfügen--> UserForm) Ändern Sie (Name)-Eigenschaft von UserForm1 von UserForm1 auf "frmAenderungen_verwalten"
      6) Wechseln Sie mit Tastenkombination Alt+F11 zurück zu Excel
      7) Ändern Sie den Namen von Arbeitsblatt Tabelle1 auf "Aenderungen_erf" und blenden Sie das Arbeitsblatt "Aenderungen_erf" aus.(Rechtsklick auf das Arbeitsblatt "Aenderungen_erf" --> Ausblenden)
      8) Aktivieren Sie das Arbeitsblatt "Tabelle2" und fügen Sie Eine Schaltfläche ein [Entwicklertools--> Einfügen--> Schaltfläche (Formularsteuerelement)]
      Benennen Sie Schaltfläche 1 um. Geben Sie Ihre Schaltfläche den Namen "START" (Später werden wir der Schaltfläche das Makro "testmich" zuweisen)

      9) Speichern Sie die Arbeitsmappe (Excel-Arbeitsmappe mit Makros (*.xlsm). Geben Sie einen neuen Namen für die Datei ein

      10) Kopieren Sie den folgenden Code und fügen Sie ihn in Modul1 ein.
      Spoiler anzeigen

      Visual Basic-Quellcode

      1. 'Code Modul1
      2. Option Explicit
      3. Option Compare Text
      4. Option Base 1
      5. 'Blattname in Dokument
      6. Public Const strTabname As String = "Aenderungen_erf"
      7. 'Internationale Einstellungen
      8. Public LgDataOrder As Long
      9. Public strDateSeparator As String
      10. Public strTimeSeperator As String
      11. Public strDecimalSeparator As String
      12. Public strDataOrder As String
      13. Public Const strDayCode As String = "DD"
      14. Public Const strMonthCode As String = "MM"
      15. Public strYearCode As String
      16. '*********************************************************************
      17. Public Declare Function GetUserName Lib "advapi32.dll" _
      18. Alias "GetUserNameA" _
      19. (ByVal lpBuffer As String, nSize As Long) As Long
      20. '*********************************************************************
      21. Public Function AnwenderName_Aktuell() As String
      22. Dim s As String
      23. Dim cnt As Long
      24. Dim ret As Long
      25. Dim pos As Integer
      26. cnt = 199
      27. s = String$(200, 0)
      28. ret = GetUserName(s, cnt)
      29. If ret <> 0 Then
      30. AnwenderName_Aktuell = Trim$(Left$(s, cnt))
      31. pos = InStr(AnwenderName_Aktuell, Chr$(0))
      32. If pos > 0 Then
      33. AnwenderName_Aktuell = Left$(AnwenderName_Aktuell, pos - 1)
      34. Else
      35. AnwenderName_Aktuell = AnwenderName_Aktuell
      36. End If
      37. Else
      38. AnwenderName_Aktuell = "User"
      39. End If
      40. On Error Resume Next
      41. Application.UserName = AnwenderName_Aktuell
      42. On Error GoTo 0
      43. End Function
      44. Sub testmich()
      45. 'uebliche prozedur
      46. 'strDayCode = Application.International(xlDayCode)
      47. 'strMonthCode = Application.International(xlMonthCode)
      48. 'strYearCode = Application.International(xlYearCode)
      49. 'strHourCode = Application.International(xlHourCode)
      50. 'strSecondCode = Application.International(xlSecondCode)
      51. If Application.International(xl4DigitYears) Then
      52. strYearCode = "YYYY" 'strYearCode & strYearCode & strYearCode & strYearCode
      53. Else
      54. strYearCode = "YY" 'strYearCode & strYearCode
      55. End If
      56. strDateSeparator = Application.International(xlDateSeparator)
      57. 'Select Case strDateSeparator
      58. ' Case Is = "."
      59. '
      60. ' Case Is = "/"
      61. '
      62. ' Case Else
      63. '
      64. ' Exit Sub
      65. 'End Select
      66. strTimeSeperator = Application.International(xlTimeSeparator)
      67. strDecimalSeparator = Application.International(xlDecimalSeparator)
      68. LgDataOrder = Application.International(xlDateOrder)
      69. Select Case LgDataOrder
      70. Case 0 'M-T-J
      71. strDataOrder = strMonthCode & strDateSeparator _
      72. & strDayCode & strDateSeparator & strYearCode
      73. Case 1 'T-M-J Deutsch
      74. strDataOrder = strDayCode & strDateSeparator _
      75. & strMonthCode & strDateSeparator & strYearCode
      76. Case 2 'J-M-T
      77. strDataOrder = strYearCode & strDateSeparator _
      78. & strMonthCode & strDateSeparator & strDayCode
      79. End Select
      80. 'ist das Blatt Aenderungen_erf vorhanden
      81. If Tabelle_vorhanden(strTabname) Then
      82. 'Dialog anzeigen
      83. frmAenderungen_verwalten.Show 0 'Modal = UserForm ist ungebunden
      84. End If
      85. End Sub
      86. Function Tabelle_vorhanden(strT_Name As String) As Boolean
      87. Dim i&
      88. For i = Application.Worksheets.Count To 1 Step -1
      89. If Application.Worksheets(i).Name = strT_Name Then Tabelle_vorhanden = True: Exit Function
      90. Next
      91. End Function
      92. Function Aenderungen_Erfa_Bear_Index(intErkennung As Integer)
      93. Dim i As Long, lgRow As Long, ws As Worksheet, wsActiv As Worksheet
      94. Dim glArray()
      95. 'intErkennung:
      96. '0=Index
      97. '1=Aenderungstext
      98. '2=Eintrag am
      99. '3 = Eintrag vom
      100. '4 = Geändert am
      101. '5 = Geändert vom
      102. On Error GoTo ErrH
      103. Application.ScreenUpdating = False
      104. Erase glArray()
      105. 'Verweis auf aktives Blatt
      106. Set wsActiv = Application.ActiveSheet
      107. 'Verweis auf Blatt aenderungen_erf
      108. Set ws = Application.ActiveWorkbook.Worksheets(strTabname)
      109. 'um einem ausgeblendeten Blatt zuzugreifen vorher Blatt aktivieren
      110. ws.Activate
      111. With ws
      112. lgRow = .Cells(Rows.Count, 1).End(xlUp).Row
      113. If lgRow > 1 Then
      114. Select Case intErkennung
      115. Case 0
      116. For i = 2 To lgRow 'To Anzahl der Zellen in Spalte A die mit Daten belegt sind
      117. 'z.B intRow = Cells(Rows.Count, 1).End(xlUp).Row
      118. ReDim Preserve glArray(i)
      119. glArray(i) = .Range(Cells(i, 1), Cells(i, 1)).Value
      120. Next
      121. Aenderungen_Erfa_Bear_Index = glArray
      122. Case 1
      123. For i = 2 To lgRow 'To Anzahl der Zellen in Spalte A die mit Daten belegt sind
      124. 'z.B intRow = Cells(Rows.Count, 1).End(xlUp).Row
      125. ReDim Preserve glArray(i)
      126. glArray(i) = .Range(Cells(i, 2), Cells(i, 2)).Value
      127. Next
      128. Aenderungen_Erfa_Bear_Index = glArray
      129. Case 2
      130. For i = 2 To lgRow 'To Anzahl der Zellen in Spalte A die mit Daten belegt sind
      131. 'z.B intRow = Cells(Rows.Count, 1).End(xlUp).Row
      132. ReDim Preserve glArray(i)
      133. glArray(i) = .Range(Cells(i, 3), Cells(i, 3)).Value
      134. Next
      135. Aenderungen_Erfa_Bear_Index = glArray
      136. Case 3
      137. For i = 2 To lgRow 'To Anzahl der Zellen in Spalte A die mit Daten belegt sind
      138. 'z.B intRow = Cells(Rows.Count, 1).End(xlUp).Row
      139. ReDim Preserve glArray(i)
      140. glArray(i) = .Range(Cells(i, 4), Cells(i, 4)).Value
      141. Next
      142. Aenderungen_Erfa_Bear_Index = glArray
      143. Case 4
      144. For i = 2 To lgRow 'To Anzahl der Zellen in Spalte A die mit Daten belegt sind
      145. 'z.B intRow = Cells(Rows.Count, 1).End(xlUp).Row
      146. ReDim Preserve glArray(i)
      147. glArray(i) = .Range(Cells(i, 5), Cells(i, 5)).Value
      148. Next
      149. Aenderungen_Erfa_Bear_Index = glArray
      150. Case 5
      151. For i = 2 To lgRow 'To Anzahl der Zellen in Spalte A die mit Daten belegt sind
      152. 'z.B intRow = Cells(Rows.Count, 1).End(xlUp).Row
      153. ReDim Preserve glArray(i)
      154. glArray(i) = .Range(Cells(i, 6), Cells(i, 6)).Value
      155. Next
      156. Aenderungen_Erfa_Bear_Index = glArray
      157. End Select
      158. Else
      159. Aenderungen_Erfa_Bear_Index = Array("0_0")
      160. End If
      161. End With
      162. Set ws = Nothing
      163. wsActiv.Activate
      164. Set wsActiv = Nothing
      165. Application.ScreenUpdating = True
      166. ErrH:
      167. If Err <> 0 Then
      168. Application.ScreenUpdating = True
      169. MsgBox Err.Description, , "FEHLER"
      170. Aenderungen_Erfa_Bear_Index = Array("F_F")
      171. Set ws = Nothing
      172. wsActiv.Activate
      173. Set wsActiv = Nothing
      174. End If
      175. End Function
      176. Function AenderungsTextLoeschen_Text_Alles(intErk As Integer, intZeile As Integer) As Boolean
      177. Dim i As Integer, lgRow As Long, lgZeile As Long
      178. Dim ws As Worksheet, wsActiv As Worksheet
      179. On Error GoTo ErrH
      180. 'intErk = 0 Text Loeschen
      181. 'intErk = 1 Alles Loeschen
      182. Application.ScreenUpdating = False
      183. 'Verweis auf aktives Blatt
      184. Set wsActiv = Application.ActiveSheet
      185. 'Verweis auf Blatt aenderungen_erf
      186. Set ws = Application.ActiveWorkbook.Worksheets(strTabname)
      187. 'um einem ausgeblendeten Blatt zuzugreifen vorher Blatt aktivieren
      188. ws.Activate
      189. With ws
      190. lgRow = .Cells(Rows.Count, 1).End(xlUp).Row
      191. 'nur 300 Zeilen erlauben
      192. If lgRow > 300 Then
      193. Set ws = Nothing
      194. wsActiv.Activate
      195. Set wsActiv = Nothing
      196. Application.ScreenUpdating = True
      197. Exit Function
      198. End If
      199. If lgRow > 1 Then
      200. Select Case intErk
      201. Case 0
      202. 'wenn intZeile +1 = lgRow dann es ist nur
      203. 'eine Zeile vorhanden. Erste Zeile
      204. If lgRow = 2 And lgRow = intZeile + 1 Then
      205. .Range(Cells(lgRow, 1), Cells(lgRow, 6)).ClearContents
      206. AenderungsTextLoeschen_Text_Alles = True
      207. Set ws = Nothing
      208. wsActiv.Activate
      209. Set wsActiv = Nothing
      210. Application.ScreenUpdating = True
      211. Exit Function
      212. End If
      213. 'wenn lgRow = intZeile + 1 dann letzte Zeile
      214. If lgRow = intZeile + 1 Then
      215. .Range(Cells(lgRow, 1), Cells(lgRow, 6)).ClearContents
      216. AenderungsTextLoeschen_Text_Alles = True
      217. Set ws = Nothing
      218. wsActiv.Activate
      219. Set wsActiv = Nothing
      220. Application.ScreenUpdating = True
      221. Exit Function
      222. End If
      223. 'von intZeile + 1 (+1) aus
      224. 'bis Ende (letzte Zeile) kopieren
      225. .Range(Cells(intZeile + 1 + 1, 1), Cells(lgRow, 6)).Copy
      226. 'intZeile (+1) einfügen
      227. .Range(Cells(intZeile + 1, 1), Cells(intZeile + 1, 1)).PasteSpecial (xlPasteValues)
      228. .Range(Cells(lgRow, 1), Cells(lgRow, 6)).ClearContents
      229. Application.CutCopyMode = False
      230. 'letzte Zeilennummer finden
      231. lgZeile = .Cells(Rows.Count, 1).End(xlUp).Row
      232. For i = 1 To lgZeile - 1
      233. .Range(Cells(i + 1, 1), Cells(i + 1, 1)).Value = i
      234. Next
      235. .Range(Cells(2, 1), Cells(2, 1)).Select
      236. AenderungsTextLoeschen_Text_Alles = True
      237. Case 1
      238. .Range(Cells(2, 1), Cells(lgRow + 1, 6)).ClearContents
      239. AenderungsTextLoeschen_Text_Alles = True
      240. Case Else
      241. AenderungsTextLoeschen_Text_Alles = False
      242. End Select
      243. Else
      244. AenderungsTextLoeschen_Text_Alles = True
      245. End If
      246. End With
      247. Set ws = Nothing
      248. wsActiv.Activate
      249. Set wsActiv = Nothing
      250. Application.ScreenUpdating = True
      251. ErrH:
      252. If Err <> 0 Then
      253. MsgBox Err.Description, , "FEHLER"
      254. AenderungsTextLoeschen_Text_Alles = False
      255. Set ws = Nothing
      256. wsActiv.Activate
      257. Set wsActiv = Nothing
      258. Application.ScreenUpdating = True
      259. End If
      260. End Function
      261. 'String Buchstabe fuer Buchstabe nach Zeichen durchsuchen
      262. Function TextnachZeichen_Durchforsten(ByVal strText As String, _
      263. ByVal strZeichen As String) As Long
      264. Dim strZ As String, i&, s&
      265. s = 0
      266. For i = 1 To Len(strText)
      267. strZ = Mid(strText, i, 1)
      268. If InStr(strZeichen, strZ) <> 0 Then
      269. s = s + 1
      270. End If
      271. Next i
      272. TextnachZeichen_Durchforsten = s
      273. End Function


      '#############################################################################################

      11) Nun können Sie der Schaltfläche das Makro "testmich" zuweisen
      Spoiler anzeigen

      ' UserForm

      Ok jetzt nehmen wir uns die UserForm "frmAenderungen_verwalten" vor.

      Wichtigste Eigenschaften von "frmAenderungen_verwalten":
      Caption: A E N D E R U N G E N E R F A S S E N / B E A R B E I T E N
      Height: 424,5
      Width: 465,75
      Left: 0
      Top: -2,25

      12) Fügen Sie der UserForm zwei Beschriftungsfeld zu. Ändern Sie die (Name)-Eigenschaft Label1 --> lbIndex, Label2--> lbAenderungen
      Spoiler anzeigen

      a) Eigenschaften von lbIndex
      Caption: INDEX
      Height: 10
      Width: 36
      Left: 12
      Top: 3

      b) Eigenschaften von lbAenderungen
      Caption: A E N D E R U N G S T E X T
      Height: 12
      Width: 216
      Left: 120
      Top: 3
      TextAlign 2 - fmTextAlignCenter

      13) Fügen Sie der UserForm eine Listbox zu. Ändern Sie die (Name)-Eigenschaft ListBox1 --> lsbAenderungen
      Spoiler anzeigen

      Eigenschaften von lsbAenderungen
      Height: 156
      Width: 449
      Left: 6
      Top: 17,25
      TextAlign 2 - fmTextAlignLeft

      14) Fügen Sie der UserForm zwei Rahmen zu. Ändern Sie die (Name)-Eigenschaften nicht.
      Spoiler anzeigen

      a) Eigenschaften von Frame1
      Caption: AENDERUNGEN
      Height: 145
      Width: 450
      Left: 6
      Top: 179
      Font: Thoma Fett 9

      b) Eigenschaften von Frame2
      Caption: DATUM AENDERN
      Height: 80
      Width: 92
      Left: 364
      Top: 318
      Font: Thoma Fett 8

      15) Aktivieren Sie Frame1. Fügen Sie vier Befehlsschaltfläche, fünf Beschriftungsfeld, zwei Textbox und ein DTPicker zu.
      Spoiler anzeigen

      a) Eigenschaften von Befehlsschaltflächen

      a.1
      (Name): cmdNeu
      Caption: NEU
      Height: 20
      Width: 65
      Left: 4
      Top: 9

      a.2
      (Name): cmdInsert
      Caption: EINFUEGEN
      Height: 20
      Width: 65
      Left: 4
      Top: 40

      a.3
      (Name): cmdEdit
      Caption: BEARBEITEN
      Height: 20
      Width: 65
      Left: 4
      Top: 78

      a.4
      (Name): cmdEinfuegen_bea
      Caption: EINFUEGEN
      Height: 20
      Width: 65
      Left: 4
      Top: 109

      b) Eigenschaften von Beschriftungsfeld

      b.1
      (Name): lbDatumNeu
      Caption: D A T U M
      Height: 16
      Width: 75
      Left: 278
      Top: 28

      b.2
      (Name): Label1
      Caption: Eingetragen am
      Height: 16
      Width: 75
      Left: 278
      Top: 79

      b.3
      (Name): Label3
      Caption: Geaendert am
      Height: 16
      Width: 75
      Left: 278
      Top: 112

      b.4
      (Name): lbDatumVorh
      Caption: Datum
      Height: 16
      Width: 80
      Left: 361
      Top: 79

      b.5
      (Name): Label4
      Caption: Datum
      Height: 16
      Width: 80
      Left: 361
      Top: 112

      c) Eigenschaften von DTPicker
      (Name): DTPicker1
      Height: 15,75
      Width: 78
      Left: 361
      Top: 28
      Value: 09.09.2013

      d) Eigenschaften von Texbox

      d.1
      (Name): txtNeu
      Height: 50
      Width: 200
      Left: 73
      Top: 10
      MultiLine: True

      d.2
      (Name): txtEdit
      Height: 50
      Width: 200
      Left: 73
      Top: 79
      MultiLine: True

      16) Aktivieren Sie Frame2. Fügen Sie zwei Optionsfeld und ein DTPicker zu.
      Spoiler anzeigen

      a) Eigenschaften von Optionsfeld

      a.1
      (Name): OptionButton1
      Caption: Eingetragen
      Height: 15
      Width: 70
      Left: 6
      Top: 8
      TextAlign 2 - fmTextAlignCenter

      a.2
      (Name): OptionButton2
      Caption: Geaendert
      Height: 15
      Width: 70
      Left: 6
      Top: 29
      TextAlign 2 - fmTextAlignCenter

      b) Eigenschaften von DTPicker
      (Name): DTPicker2
      Height: 18
      Width: 77,25
      Left: 7
      Top: 48
      Value: 09.09.2013

      17) Aktivieren Sie die UserForm "frmAenderungen_verwalten" und fügen Sie vier Befehlsschaltfläche zu.
      Spoiler anzeigen

      a) Eigenschaften von Befehlsschaltflächen

      a.1
      (Name): cmdLoeschen
      Caption: TEXT LOESCHEN
      Height: 30
      Width: 75
      Left: 6
      Top: 326

      a.2
      (Name): cmdAlles
      Caption: ALLES LOESCHEN
      Height: 30
      Width: 75
      Left: 6
      Top: 364

      a.3
      (Name): cmdUndo
      Caption: ALLES VERWERFEN
      Height: 30
      Width: 75
      Left: 285
      Top: 326
      WordWrap: True

      a.4
      (Name): cmdExit
      Caption: EXIT
      Height: 30
      Width: 75
      Left: 285
      Top: 364


      '################################################################################
      'UserForm-Gestaltung Ende
      '################################################################################

      18) Klicken Sie mit der rechten Maustaste auf eine freie Fläche der UserForm "frmAenderungen_verwalten" und wählen aus dem Kontexmenü den Befehl"Code anzeigen". Im Codebereich fügen Sie folgende ereignismakros zu

      Spoiler anzeigen

      Quellcode

      1. Option Explicit
      2. 'Option Compare Text
      3. Option Base 1
      4. Private blAll As Boolean
      5. Dim txtInBearbeitung As String
      6. 'Variablen die in Bearbeitung benötigt werden
      7. Dim varIndex, varAender, varDat, varUser, varDat_geaen, varUser_geaen
      8. 'alle Aenderungen verwerfen
      9. Dim varStand_1_Index, varStand_1_Aender, varStand_1_Dat, varStand_1_User, varStand_1_Datgeaen, varStand_1_Usergeaen
      10. '###############################################
      11. '#####################################################
      12. 'alle Aenderungstexte werden gelöscht
      13. Private Sub cmdAlles_Click()
      14. If MsgBox("Alle Aenderungstexte werden geloescht. Fortfahren?", vbOKCancel, "NEU PROJEKT") = vbOK Then
      15. 'alles löschen
      16. If AenderungsTextLoeschen_Text_Alles(1, 0) Then
      17. Call Form_Clear
      18. Call VariablenInitialisieren
      19. Me.cmdUndo.Enabled = True
      20. blAll = True
      21. End If
      22. End If
      23. End Sub
      24. Private Sub cmdEdit_Click()
      25. Me.txtNeu.Value = ""
      26. Me.txtNeu.Enabled = False
      27. Me.txtEdit.Enabled = True
      28. txtEdit.Value = varAender(Me.lsbAenderungen.ListIndex + 2)
      29. Me.cmdLoeschen.Enabled = False
      30. Me.cmdLoeschen.Caption = "TEXT LOESCHEN"
      31. Me.lbDatumVorh.Caption = varDat(Me.lsbAenderungen.ListIndex + 2)
      32. Me.Label4.Caption = varDat_geaen(Me.lsbAenderungen.ListIndex + 2)
      33. Me.OptionButton1.Value = False
      34. Me.OptionButton2.Value = False
      35. Me.OptionButton1.Enabled = True
      36. Me.OptionButton2.Enabled = True
      37. txtInBearbeitung = txtEdit.Value
      38. On Error GoTo ErrH
      39. 'Me.DTPicker2.Value = varDat(Me.lsbAenderungen.ListIndex + 2)
      40. Me.DTPicker2.Value = Date
      41. If Me.DTPicker2.Value = "00:00:00" Then
      42. Me.DTPicker2.Value = Date
      43. End If
      44. ErrH:
      45. If Err <> 0 Then
      46. Me.DTPicker2.Value = Date
      47. End If
      48. On Error GoTo 0
      49. End Sub
      50. 'vorhandene Texte bearbeitet. wird an der gleichen stelle neu eingefügt
      51. Private Sub cmdEinfuegen_bea_Click()
      52. Dim strText As String, strZeichen$
      53. strZeichen = " " & vbCr & vbBack & vbCrLf & vbLf & vbTab & vbVerticalTab
      54. strText = Me.txtEdit.Value
      55. strText = Trim$(strText)
      56. If Trim$(txtInBearbeitung) = strText And Me.OptionButton1.Value = False _
      57. And Me.OptionButton2.Value = False Then
      58. txtInBearbeitung = ""
      59. Me.txtEdit.Value = ""
      60. Me.txtEdit.SetFocus
      61. Me.OptionButton1.Value = False
      62. Me.OptionButton2.Value = False
      63. Me.OptionButton1.Enabled = False
      64. Me.OptionButton2.Enabled = False
      65. 'MsgBox "Text ist nicht geaendert"
      66. Exit Sub
      67. Else 'entweder Text geaendert oder eine von OptionButton gewählt
      68. If TextnachZeichen_Durchforsten(strText, strZeichen) <> Len(strText) Then
      69. Select Case True
      70. Case Me.OptionButton1.Value
      71. Call Text_Geaendert_Eintragen(0, Me.lsbAenderungen.ListIndex, 3)
      72. Case Me.OptionButton2.Value
      73. Call Text_Geaendert_Eintragen(0, Me.lsbAenderungen.ListIndex, 5)
      74. Case Else
      75. Call Text_Geaendert_Eintragen(0, Me.lsbAenderungen.ListIndex)
      76. End Select
      77. Call Form_Clear
      78. Call VariablenInitialisieren
      79. Me.cmdUndo.Enabled = True
      80. blAll = True
      81. Else
      82. MsgBox "Leerzeichen werden nicht eingefügt.", vbOKOnly + vbInformation
      83. Me.txtEdit.Value = ""
      84. Me.txtEdit.SetFocus
      85. End If
      86. End If
      87. End Sub
      88. 'Neue Text wird der liste angehängt
      89. Private Sub cmdInsert_Click()
      90. Dim strText As String, strZeichen$
      91. strZeichen = " " & vbCr & vbBack & vbCrLf & vbLf & vbTab & vbVerticalTab
      92. strText = Me.txtNeu.Value
      93. strText = Trim$(strText)
      94. If TextnachZeichen_Durchforsten(strText, strZeichen) <> Len(strText) Then
      95. Call Text_Geaendert_Eintragen(1, 5001)
      96. Call Form_Clear
      97. Call VariablenInitialisieren
      98. Me.cmdUndo.Enabled = True
      99. blAll = True
      100. Else
      101. MsgBox "Leerzeichen werden nicht eingefügt.", vbOKOnly + vbInformation
      102. Me.txtNeu.Value = ""
      103. Me.txtNeu.SetFocus
      104. End If
      105. End Sub
      106. 'Neue Text wird von der Liste wegradiert
      107. Private Sub cmdLoeschen_Click()
      108. If Trim$(Me.txtEdit.Value) <> "" Then Exit Sub
      109. If MsgBox("Aenderungstext : " & vbCr & _
      110. varAender(Me.lsbAenderungen.ListIndex + 2) & vbCr & "Loeschen?", vbOKCancel + vbInformation, "NN NNN") = vbOK Then
      111. If AenderungsTextLoeschen_Text_Alles(0, Me.lsbAenderungen.ListIndex + 1) Then
      112. Call Form_Clear
      113. Call VariablenInitialisieren
      114. Me.cmdUndo.Enabled = True
      115. blAll = True
      116. End If
      117. End If
      118. End Sub
      119. ' Click-Ereignis cmdNeu
      120. Private Sub cmdNeu_Click()
      121. Me.txtNeu.Enabled = True
      122. Me.cmdEinfuegen_bea.Enabled = False
      123. Me.DTPicker1.Value = Date
      124. Me.txtNeu.SetFocus
      125. Me.txtEdit.Value = ""
      126. Me.txtEdit.Enabled = False
      127. Me.OptionButton1.Value = False
      128. Me.OptionButton2.Value = False
      129. Me.OptionButton1.Enabled = False
      130. Me.OptionButton2.Enabled = False
      131. End Sub
      132. ' Click-Ereignis cmdUndo
      133. Private Sub cmdUndo_Click()
      134. If MsgBox("Alle Vorgaenge werden zurückgesetzt. Fortfahren?", vbOKCancel + vbQuestion, "NEU PROJEKT") = vbOK Then
      135. Call AenderungsText_ZurueckSchreiben
      136. Call Form_Clear
      137. Call VariablenInitialisieren
      138. blAll = True
      139. End If
      140. End Sub
      141. ' Click-Ereignis lsbAenderungen
      142. Private Sub lsbAenderungen_Click()
      143. Me.cmdLoeschen.Enabled = (Me.lsbAenderungen.ListCount > -1)
      144. If Me.cmdLoeschen.Enabled = True Then
      145. Me.cmdLoeschen.Caption = "INDEX [ " & Me.lsbAenderungen.ListIndex + 1 & _
      146. " ] LOESCHEN"
      147. End If
      148. Me.lbDatumVorh.Caption = varDat(Me.lsbAenderungen.ListIndex + 2)
      149. Me.Label4.Caption = varDat_geaen(Me.lsbAenderungen.ListIndex + 2)
      150. Me.cmdEdit.Enabled = (Me.lsbAenderungen.ListCount > -1)
      151. Me.txtEdit.Value = ""
      152. Me.txtEdit.Enabled = False
      153. End Sub
      154. ' DblClick-Ereignis lsbAenderungen
      155. Private Sub lsbAenderungen_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
      156. If Me.lsbAenderungen.ListIndex < 0 Then Cancel = True: Exit Sub
      157. MsgBox "INDEX : " & Me.lsbAenderungen.ListIndex + 1 & vbCr & vbCr _
      158. & "TEXT : " & varAender(Me.lsbAenderungen.ListIndex + 2) & vbCr & vbCr _
      159. & "EINTRAG AM : " & varDat(Me.lsbAenderungen.ListIndex + 2) & vbCr _
      160. & "EINTRAG VOM : " & varUser(Me.lsbAenderungen.ListIndex + 2) & vbCr _
      161. & "GEAENDERT AM : " & varDat_geaen(Me.lsbAenderungen.ListIndex + 2) & vbCr _
      162. & "GEAENDERT VOM : " & varUser_geaen(Me.lsbAenderungen.ListIndex + 2) & vbCr
      163. End Sub
      164. 'DblClick-Ereignis OptionButton1
      165. Private Sub OptionButton1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
      166. Cancel = True
      167. Me.OptionButton1.Value = False
      168. End Sub
      169. 'DblClick-Ereignis OptionButton2
      170. Private Sub OptionButton2_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
      171. Cancel = True
      172. Me.OptionButton2.Value = False
      173. End Sub
      174. 'Change-Ereignis txtEdit
      175. Private Sub txtEdit_Change()
      176. Me.cmdEinfuegen_bea.Enabled = (Me.txtEdit.Value <> "")
      177. Me.cmdLoeschen.Enabled = (Me.txtEdit.Value = "")
      178. If Me.cmdLoeschen.Enabled = True Then
      179. Me.cmdLoeschen.Caption = "INDEX [ " & Me.lsbAenderungen.ListIndex + 1 & _
      180. " ] LOESCHEN"
      181. End If
      182. Me.DTPicker2.Enabled = (Me.txtEdit.Value <> "")
      183. Me.OptionButton1.Value = False
      184. Me.OptionButton2.Value = False
      185. Me.OptionButton1.Enabled = (Me.txtEdit.Value <> "")
      186. Me.OptionButton2.Enabled = (Me.txtEdit.Value <> "")
      187. If Len(Me.txtEdit.Value) <= 0 Then Exit Sub
      188. If Len(Me.txtEdit.Value) > 120 Then
      189. Me.txtEdit.Value = Left$(Me.txtEdit.Value, 120)
      190. End If
      191. End Sub
      192. 'KeyDown-Ereignis txtEdit
      193. Private Sub txtEdit_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
      194. If KeyCode = 13 Then 'Return-Taster Eingabetaster
      195. KeyCode = 0
      196. End If
      197. End Sub
      198. 'Change-Ereignis txtNeu
      199. Private Sub txtNeu_Change()
      200. Me.cmdInsert.Enabled = (Me.txtNeu.Value <> "")
      201. Me.cmdNeu.Enabled = (Me.txtNeu.Value = "")
      202. Me.DTPicker1.Enabled = (Me.txtNeu.Value <> "")
      203. Me.txtEdit.Value = ""
      204. Me.txtEdit.Enabled = False
      205. If Len(Me.txtNeu.Value) <= 0 Then Exit Sub
      206. If Len(Me.txtNeu.Value) > 120 Then
      207. Me.txtNeu.Value = Left$(Me.txtNeu.Value, 120)
      208. End If
      209. End Sub
      210. 'KeyDown-Ereignis txtNeu
      211. Private Sub txtNeu_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
      212. If KeyCode = 13 Then 'Return-Taste Eingabetaster
      213. KeyCode = 0
      214. End If
      215. End Sub
      216. Private Sub UserForm_Initialize()
      217. 'intErkennung:
      218. '0=Index
      219. '1=Aenderungstext
      220. '2=Datum
      221. Call VariablenInitialisieren
      222. varStand_1_Index = varIndex
      223. If varStand_1_Index(1) = "F_F" Then Exit Sub
      224. varStand_1_Aender = varAender
      225. varStand_1_Dat = varDat
      226. varStand_1_User = varUser
      227. varStand_1_Datgeaen = varDat_geaen
      228. varStand_1_Usergeaen = varUser_geaen
      229. 'Application.ScreenUpdating = True
      230. End Sub
      231. Private Sub cmdExit_Click()
      232. Unload Me
      233. End
      234. End Sub
      235. Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
      236. 'If MsgBox("wirklich verlassen?", vbOKCancel + vbQuestion, "NEU PROJEKT") = vbOK Then
      237. Cancel = False
      238. If blAll = True Then
      239. Me.Hide
      240. Call AenderungsBlattFormatieren
      241. End If
      242. blAll = False
      243. If CloseMode = 0 Then Call cmdExit_Click
      244. Exit Sub
      245. ' Else
      246. Cancel = True: Exit Sub
      247. ' End If
      248. 'Dialogschliessen über das Kreuz verhindern
      249. 'If CloseMode <> 1 Then Cancel = True: Exit Sub
      250. End Sub
      251. Private Sub VariablenInitialisieren()
      252. 'intErkennung:
      253. '0 = Index
      254. '1 = Aenderungstext
      255. '2 = Datum
      256. '3 = User
      257. Dim i As Long
      258. txtInBearbeitung = ""
      259. varIndex = Aenderungen_Erfa_Bear_Index(0)
      260. If varIndex(1) = "F_F" Then
      261. Me.cmdEinfuegen_bea.Enabled = False
      262. Me.cmdInsert.Enabled = False
      263. Me.cmdAlles.Enabled = (Me.lsbAenderungen.ListIndex > -1)
      264. Me.cmdAlles.Enabled = False
      265. Me.cmdEdit.Enabled = False
      266. Me.cmdLoeschen.Enabled = False
      267. Me.cmdUndo.Enabled = False
      268. Me.cmdNeu.Enabled = False
      269. Me.txtNeu.Enabled = False
      270. Me.txtEdit.Enabled = False
      271. Me.cmdLoeschen.Enabled = False
      272. Me.DTPicker1.Enabled = False
      273. Me.DTPicker2.Enabled = False
      274. Me.DTPicker1.Value = Date
      275. Me.DTPicker2.Value = Date
      276. Me.Label1.Caption = "Eingetragen am"
      277. Me.Label3.Caption = "Geaendert am"
      278. Me.Label4.Caption = ""
      279. Me.OptionButton1.Value = False
      280. Me.OptionButton2.Value = False
      281. Me.OptionButton1.Enabled = False
      282. Me.OptionButton2.Enabled = False
      283. Me.lbDatumNeu.Caption = " D A T U M "
      284. Me.lbDatumVorh.Caption = ""
      285. Me.lbIndex.Caption = "I N D E X"
      286. Me.lbAenderungen.Caption = "A E N D E R U G S T E X T"
      287. Exit Sub
      288. End If
      289. varAender = Aenderungen_Erfa_Bear_Index(1)
      290. varDat = Aenderungen_Erfa_Bear_Index(2)
      291. varUser = Aenderungen_Erfa_Bear_Index(3)
      292. varDat_geaen = Aenderungen_Erfa_Bear_Index(4)
      293. varUser_geaen = Aenderungen_Erfa_Bear_Index(5)
      294. If varIndex(1) = "0_0" Then 'Liste ist leer
      295. Me.cmdEinfuegen_bea.Enabled = False
      296. Me.cmdInsert.Enabled = False
      297. Me.cmdAlles.Enabled = (Me.lsbAenderungen.ListIndex > -1)
      298. Me.cmdAlles.Enabled = False
      299. Me.cmdEdit.Enabled = False
      300. Me.cmdLoeschen.Enabled = False
      301. Me.cmdUndo.Enabled = False
      302. Me.OptionButton1.Value = False
      303. Me.OptionButton2.Value = False
      304. Me.OptionButton1.Enabled = False
      305. Me.OptionButton2.Enabled = False
      306. Me.txtNeu.Enabled = False
      307. Me.txtEdit.Enabled = False
      308. Me.cmdLoeschen.Enabled = False
      309. Me.DTPicker1.Enabled = False
      310. Me.DTPicker2.Enabled = False
      311. Me.DTPicker1.Value = Date
      312. Me.DTPicker2.Value = Date
      313. Me.Label1.Caption = "Eingetragen am"
      314. Me.Label3.Caption = "Geaendert am"
      315. Me.Label4.Caption = ""
      316. Me.lbDatumNeu.Caption = " D A T U M "
      317. Me.lbDatumVorh.Caption = ""
      318. Me.lbIndex.Caption = "I N D E X"
      319. Me.lbAenderungen.Caption = "A E N D E R U G S T E X T"
      320. Else
      321. For i = LBound(varIndex) + 1 To UBound(varIndex)
      322. If i >= 11 Then
      323. Me.lsbAenderungen.AddItem varIndex(i) & " " & Trim$(varAender(i)) '& " " & varDat(i)
      324. Else
      325. Me.lsbAenderungen.AddItem " " & varIndex(i) & " " & Trim$(varAender(i)) '& " " & varDat(i)
      326. End If
      327. Next
      328. Me.cmdEinfuegen_bea.Enabled = False
      329. Me.cmdInsert.Enabled = False
      330. Me.cmdAlles.Enabled = (Me.lsbAenderungen.ListIndex < 0)
      331. Me.cmdEdit.Enabled = False
      332. Me.cmdLoeschen.Enabled = False
      333. Me.cmdUndo.Enabled = False
      334. Me.OptionButton1.Value = False
      335. Me.OptionButton2.Value = False
      336. Me.OptionButton1.Enabled = False
      337. Me.OptionButton2.Enabled = False
      338. Me.txtNeu.Enabled = False
      339. Me.txtEdit.Enabled = False
      340. Me.DTPicker1.Enabled = False
      341. Me.DTPicker2.Enabled = False
      342. Me.DTPicker1.Value = Date
      343. ' Me.DTPicker2.Value = Date
      344. Me.Label1.Caption = "Eingetragen am"
      345. Me.Label3.Caption = "Geaendert am"
      346. Me.Label4.Caption = ""
      347. Me.lbDatumNeu.Caption = " D A T U M "
      348. Me.lbDatumVorh.Caption = ""
      349. Me.lbIndex.Caption = "I N D E X"
      350. Me.lbAenderungen.Caption = "A E N D E R U G S T E X T"
      351. Me.lsbAenderungen.Value = Me.lsbAenderungen.List(0)
      352. Me.lsbAenderungen.ControlTipText = "Klicken Sie doppelt auf die Zeile um alle Daten zu sehen."
      353. End If
      354. End Sub
      355. Private Sub Form_Clear()
      356. Me.lsbAenderungen.Clear
      357. Me.txtEdit.Value = ""
      358. Me.txtNeu.Value = ""
      359. Me.lbDatumVorh.Caption = ""
      360. Me.Label4.Caption = ""
      361. End Sub
      362. Private Sub AenderungsText_ZurueckSchreiben()
      363. Dim i As Integer, lgRow As Long
      364. Dim ws As Worksheet, wsActiv As Worksheet
      365. On Error GoTo ErrH
      366. Application.ScreenUpdating = False
      367. 'Verweis auf aktives Blatt
      368. Set wsActiv = Application.ActiveSheet
      369. 'Verweis auf Blatt aenderungen_erf
      370. Set ws = Application.ActiveWorkbook.Worksheets(strTabname)
      371. 'um einem ausgeblendeten Blatt zuzugreifen vorher Blatt aktivieren
      372. ws.Activate
      373. With ws
      374. lgRow = .Cells(Rows.Count, 1).End(xlUp).Row
      375. If lgRow > 1 Then 'mehr als eine Zeile
      376. 'Blatt ausräumen
      377. .Range(Cells(2, 1), Cells(lgRow, 6)).ClearContents
      378. 'vorher gespeicherten Werte zurueckschreiben
      379. For i = 1 To UBound(varStand_1_Index) - 1
      380. .Range(Cells(i + 1, 1), Cells(i + 1, 1)).Value = i
      381. .Range(Cells(i + 1, 2), Cells(i + 1, 2)).Value = varStand_1_Aender(i + 1)
      382. .Range(Cells(i + 1, 3), Cells(i + 1, 3)).Value = varStand_1_Dat(i + 1)
      383. .Range(Cells(i + 1, 4), Cells(i + 1, 4)).Value = varStand_1_User(i + 1)
      384. .Range(Cells(i + 1, 5), Cells(i + 1, 5)).Value = varStand_1_Datgeaen(i + 1)
      385. .Range(Cells(i + 1, 6), Cells(i + 1, 6)).Value = varStand_1_Usergeaen(i + 1)
      386. Next
      387. Else
      388. For i = 1 To UBound(varStand_1_Index) - 1
      389. .Range(Cells(i + 1, 1), Cells(i + 1, 1)).Value = i
      390. .Range(Cells(i + 1, 2), Cells(i + 1, 2)).Value = varStand_1_Aender(i + 1)
      391. .Range(Cells(i + 1, 3), Cells(i + 1, 3)).Value = varStand_1_Dat(i + 1)
      392. .Range(Cells(i + 1, 4), Cells(i + 1, 4)).Value = varStand_1_User(i + 1)
      393. .Range(Cells(i + 1, 5), Cells(i + 1, 5)).Value = varStand_1_Datgeaen(i + 1)
      394. .Range(Cells(i + 1, 6), Cells(i + 1, 6)).Value = varStand_1_Usergeaen(i + 1)
      395. Next
      396. End If
      397. End With
      398. Set ws = Nothing
      399. wsActiv.Activate
      400. Set wsActiv = Nothing
      401. Application.ScreenUpdating = True
      402. ErrH:
      403. If Err <> 0 Then
      404. MsgBox Err.Description, , "FEHLER"
      405. Set ws = Nothing
      406. wsActiv.Activate
      407. Set wsActiv = Nothing
      408. Application.ScreenUpdating = True
      409. End If
      410. End Sub
      411. Private Sub Text_Geaendert_Eintragen(intErkennung As Integer, intPos As Integer, Optional varDatumAenderung As Variant)
      412. Dim i As Integer, lgRow As Long, strUserName$
      413. Dim ws As Worksheet, wsActiv As Worksheet
      414. '0 = Texte geaendert Werte aus txtEdit
      415. '1= Texte neu
      416. On Error GoTo ErrH
      417. Application.ScreenUpdating = False
      418. 'Verweis auf aktives Blatt
      419. Set wsActiv = Application.ActiveSheet
      420. 'Verweis auf Blatt aenderungen_erf
      421. Set ws = Application.ActiveWorkbook.Worksheets(strTabname)
      422. 'um einem ausgeblendeten Blatt zuzugreifen vorher Blatt aktivieren
      423. ws.Activate
      424. strUserName = AnwenderName_Aktuell()
      425. lgRow = ws.Cells(Rows.Count, 1).End(xlUp).Row
      426. With ws
      427. Select Case intErkennung
      428. Case 0 'geaenderte Texte
      429. 'Zeile ausräumen
      430. .Range(Cells(intPos + 2, 2), Cells(intPos + 2, 2)).ClearContents
      431. .Range(Cells(intPos + 2, 6), Cells(intPos + 2, 6)).ClearContents
      432. .Range(Cells(intPos + 2, 2), Cells(intPos + 2, 2)).Value = Me.txtEdit.Value
      433. '.Range(Cells(intPos + 2, 3), Cells(intPos + 2, 3)).Value = CStr(Me.DTPicker2.Value)
      434. .Range(Cells(intPos + 2, 6), Cells(intPos + 2, 6)).Value = strUserName
      435. If Not IsMissing(varDatumAenderung) Then
      436. Select Case varDatumAenderung
      437. Case 3
      438. .Range(Cells(intPos + 2, 3), Cells(intPos + 2, 3)).Value = CStr(Me.DTPicker2.Value)
      439. If .Range(Cells(intPos + 2, 5), Cells(intPos + 2, 5)).Value = "" Then
      440. .Range(Cells(intPos + 2, 5), Cells(intPos + 2, 5)).Value = CStr(Me.DTPicker2.Value)
      441. End If
      442. Case 5
      443. .Range(Cells(intPos + 2, 5), Cells(intPos + 2, 5)).Value = CStr(Me.DTPicker2.Value)
      444. If .Range(Cells(intPos + 2, 3), Cells(intPos + 2, 3)).Value = "" Then
      445. .Range(Cells(intPos + 2, 3), Cells(intPos + 2, 3)).Value = CStr(Me.DTPicker2.Value)
      446. End If
      447. End Select
      448. Else
      449. .Range(Cells(intPos + 2, 5), Cells(intPos + 2, 5)).Value = CStr(Me.DTPicker2.Value) 'ist es nicht überflüssig?
      450. End If
      451. Case 1 'Texte neu
      452. .Range(Cells(lgRow + 1, 1), Cells(lgRow + 1, 1)).Value = lgRow
      453. .Range(Cells(lgRow + 1, 2), Cells(lgRow + 1, 2)).Value = Me.txtNeu.Value
      454. .Range(Cells(lgRow + 1, 3), Cells(lgRow + 1, 3)).Value = CStr(Me.DTPicker1.Value)
      455. .Range(Cells(lgRow + 1, 4), Cells(lgRow + 1, 4)).Value = strUserName
      456. End Select
      457. End With
      458. Set ws = Nothing
      459. wsActiv.Activate
      460. Set wsActiv = Nothing
      461. Application.ScreenUpdating = True
      462. ErrH:
      463. If Err <> 0 Then
      464. MsgBox Err.Description, , "FEHLER"
      465. Set ws = Nothing
      466. wsActiv.Activate
      467. Set wsActiv = Nothing
      468. Application.ScreenUpdating = True
      469. End If
      470. End Sub
      471. Private Sub AenderungsBlattFormatieren()
      472. Dim i As Integer, lgRow As Long
      473. Dim ws As Worksheet, wsActiv As Worksheet
      474. Dim strPrintArea$
      475. On Error GoTo ErrH
      476. Application.ScreenUpdating = True
      477. DoEvents
      478. Me.Hide
      479. Application.ScreenUpdating = False
      480. 'Verweis auf aktives Blatt
      481. Set wsActiv = Application.ActiveSheet
      482. 'Verweis auf Blatt aenderungen_erf
      483. Set ws = Application.ActiveWorkbook.Worksheets(strTabname)
      484. 'um einem ausgeblendeten Blatt zuzugreifen vorher Blatt aktivieren
      485. ws.Activate
      486. Application.ScreenUpdating = False
      487. lgRow = ws.Cells(Rows.Count, 1).End(xlUp).Row
      488. With ws
      489. 'Druckbereich zuweisen
      490. strPrintArea = .Range(Cells(1, 1), Cells(lgRow, 6)).Address
      491. 'alle Zellen haben Textformat
      492. .Range(Cells(1, 2), Cells(lgRow, 6)).NumberFormat = "@"
      493. 'in Spalte 2 ab Zeile 2 Zeilenumbruch
      494. .Range(Cells(2, 2), Cells(lgRow, 2)).WrapText = True
      495. 'von der ersten Spalte bis zu vierten Spalte
      496. .Range(Cells(1, 1), Cells(1, 6)).HorizontalAlignment = xlCenter
      497. .Range(Cells(1, 1), Cells(1, 6)).VerticalAlignment = xlBottom
      498. .Range(Cells(1, 1), Cells(1, 6)).Font.Name = "Arial"
      499. .Range(Cells(1, 1), Cells(1, 6)).Font.FontStyle = "Fett"
      500. .Range(Cells(1, 1), Cells(1, 6)).Font.Size = 10
      501. .Range(Cells(2, 1), Cells(lgRow, 1)).HorizontalAlignment = xlCenter
      502. .Range(Cells(2, 1), Cells(lgRow, 1)).VerticalAlignment = xlBottom
      503. .Range(Cells(2, 3), Cells(lgRow, 3)).HorizontalAlignment = xlRight
      504. .Range(Cells(2, 3), Cells(lgRow, 3)).VerticalAlignment = xlBottom
      505. .Range(Cells(2, 5), Cells(lgRow, 5)).HorizontalAlignment = xlRight
      506. .Range(Cells(2, 5), Cells(lgRow, 5)).VerticalAlignment = xlBottom
      507. .Range(Cells(2, 4), Cells(lgRow, 4)).HorizontalAlignment = xlRight
      508. .Range(Cells(2, 4), Cells(lgRow, 4)).VerticalAlignment = xlBottom
      509. .Range(Cells(2, 6), Cells(lgRow, 6)).HorizontalAlignment = xlRight
      510. .Range(Cells(2, 6), Cells(lgRow, 6)).VerticalAlignment = xlBottom
      511. .Range(Cells(1, 1), Cells(1, 1)).Value = "INDEX"
      512. .Range(Cells(1, 2), Cells(1, 2)).Value = "AENDERUNGSTEXT"
      513. .Range(Cells(1, 3), Cells(1, 3)).Value = "EINTRAG AM"
      514. .Range(Cells(1, 4), Cells(1, 4)).Value = "EINTRAG VON"
      515. .Range(Cells(1, 5), Cells(1, 5)).Value = "GEAENDERT AM"
      516. .Range(Cells(1, 6), Cells(1, 6)).Value = "GEAENDERT VON"
      517. 'Zeilenwerte
      518. .Rows("1:1").RowHeight = 17
      519. .Rows("2:400").RowHeight = 45
      520. 'Spaltenwerte
      521. .Columns("A:A").ColumnWidth = 6
      522. .Columns("B:B").ColumnWidth = 68
      523. .Columns("C:C").ColumnWidth = 15
      524. .Columns("D:D").ColumnWidth = 18
      525. .Columns("E:E").ColumnWidth = 15
      526. .Columns("F:F").ColumnWidth = 18
      527. .Range("A1").Select
      528. 'Drucken
      529. With ActiveSheet.PageSetup
      530. .PrintTitleRows = "$1:$1"
      531. ' .PrintArea = ""
      532. .PrintArea = strPrintArea
      533. ' .PrintTitleColumns = ""
      534. .PrintGridlines = True
      535. .LeftHeader = "&D &T"
      536. .CenterHeader = ActiveWorkbook.Name
      537. ' .RightHeader = ""
      538. ' .LeftFooter = ""
      539. .CenterFooter = ActiveWorkbook.FullName
      540. .RightFooter = "&P& /&N"
      541. .LeftMargin = Application.CentimetersToPoints(1.4)
      542. .RightMargin = Application.CentimetersToPoints(1.4)
      543. .TopMargin = Application.CentimetersToPoints(2#)
      544. .BottomMargin = Application.CentimetersToPoints(2#)
      545. .HeaderMargin = Application.CentimetersToPoints(1.2)
      546. .FooterMargin = Application.CentimetersToPoints(1.2)
      547. ' .PrintHeadings = False
      548. ' .PrintComments = xlPrintNoComments
      549. .CenterHorizontally = True
      550. ' .CenterVertically = False
      551. .Orientation = xlLandscape
      552. ' .Draft = False
      553. .PaperSize = xlPaperA4
      554. ' .FirstPageNumber = xlAutomatic
      555. ' .Order = xlDownThenOver
      556. ' .BlackAndWhite = False
      557. .Zoom = 95
      558. '.PrintErrors = xlPrintErrorsDisplayed
      559. End With
      560. ' '.PrintOut
      561. End With
      562. Set ws = Nothing
      563. wsActiv.Activate
      564. Set wsActiv = Nothing
      565. Application.ScreenUpdating = True
      566. ErrH:
      567. If Err <> 0 Then
      568. MsgBox Err.Description, , "FEHLER"
      569. Set ws = Nothing
      570. wsActiv.Activate
      571. Set wsActiv = Nothing
      572. Application.ScreenUpdating = True
      573. End If
      574. End Sub


      Der Code ist unter Excel 2003/2010/2013 (deutsche Version) 32bit lauffähig.

      Ich wünsche euch viel Spaß damit.

      Edit by ~blaze~:
      *Code durch VB-Tag ersetzt*

      aufgrund des Datenumfangs Spoiler hinzugefügt ~VaporiZed

      Dieser Beitrag wurde bereits 2 mal editiert, zuletzt von „VaporiZed“ ()