Wenn ihr gleich meine Programmierung seht, werdet ihr die Hände über dem Kopf zusammenschlagen.
Deshalb brauche ich ja eure Hilfe:
Option Explicit
Public I_jahr As Integer
Public I_monat As Integer
Public I_tag As Integer
Private Sub UserForm_Activate()
Dim Ne As String, Printer$, i%, a%
DTPicker1 = (Now) + 1
Select Case Sheets("Leer").Cells(1, 256).Value
Case 11:
Sheets("Leer").Cells(110, 110) = ""
Sheets("Leer").Cells(111, 111) = ""
Sheets("Leer").Cells(112, 112) = ""
For a = 1 To 3
Application.ScreenUpdating = False
If a = 1 Then Printer = "\\L31SRV20\L31PRN112 auf Ne"
If a = 2 Then Printer = "\\L31SRV20\L31PRN082 auf Ne"
If a = 3 Then Printer = "\\L31SRV20\L31PRN085 auf Ne"
On Error Resume Next
For i = 1 To 99
Ne = Format(i, "00")
Err.Number = 0
Application.ActivePrinter = Printer & Ne & ":"
If Err.Number = 0 Then
If a = 1 Then Sheets("Leer").Cells(110, 110) = Printer & Ne & ":"
If a = 2 Then Sheets("Leer").Cells(111, 111) = Printer & Ne & ":"
If a = 3 Then Sheets("Leer").Cells(112, 112) = Printer & Ne & ":"
Exit For
End If
Next i
Next a
If Sheets("Leer").Cells(110, 110) "" Then CheckBox1.Visible = True
If Sheets("Leer").Cells(111, 111) "" Then CheckBox2.Visible = True
If Sheets("Leer").Cells(112, 112) "" Then CheckBox3.Visible = True
If Sheets("Leer").Cells(110, 110) "" Then Label10.Visible = True
If Sheets("Leer").Cells(111, 111) "" Then Label11.Visible = True
If Sheets("Leer").Cells(112, 112) "" Then Label12.Visible = True
If Environ("ComputerName") = "W0162041" Then CheckBox1.Value = True
End Select
End Sub
Private Sub CommandButton1_Click()
Dim printOK, z2, Liste, Namea, print1, print2, print3
print1 = Sheets("Leer").Cells(110, 110)
print2 = Sheets("Leer").Cells(111, 111)
print3 = Sheets("Leer").Cells(112, 112)
I_tag = CInt(DTPicker1.Day)
I_monat = CInt(DTPicker1.Month)
I_jahr = CInt(DTPicker1.Year)
If OptionButton1 False Then Sheets("Leer").Cells(1, 255).Value = "1"
If OptionButton2 False Then Sheets("Leer").Cells(1, 255).Value = "2"
If OptionButton3 False Then Sheets("Leer").Cells(1, 255).Value = "3"
Select Case Sheets("Leer").Cells(1, 256).Value
Case 11, 12, 13, 14:
Sheets("Drucken").Select: Cells(2, 4).Select
ActiveCell.FormulaR1C1 = "Für den " & I_tag & ". " & I_monat & ". " &
I_jahr
Case 21, 22, 23, 24:
Sheets("DruckenGF").Select: Cells(19, 6).Select
ActiveCell.FormulaR1C1 = "Für den " & I_tag & ". " & I_monat & ". " &
I_jahr
End Select
If CheckBox1.Value = False And CheckBox2.Value = False And CheckBox3.Value
= False Then printOK = Application.Dialogs(xlDialogPrinterSetup).Show
update_aus ' Aktualisierung aus
Range("a1").Select
' Drucken
If CheckBox1.Value = False And CheckBox2.Value = False And CheckBox3.Value
= False Then If printOK = False Then GoTo ende
UserForm2.Automatisch
If CheckBox1 = True Then ActiveWindow.SelectedSheets.PrintOut From:=1,
to:=1, Copies:=Sheets("Leer").Cells(1, 255), ActivePrinter:=print1,
Collate:=True
If CheckBox2 = True Then ActiveWindow.SelectedSheets.PrintOut From:=1,
to:=1, Copies:=Sheets("Leer").Cells(1, 255), ActivePrinter:=print2,
Collate:=True
If CheckBox3 = True Then ActiveWindow.SelectedSheets.PrintOut From:=1,
to:=1, Copies:=Sheets("Leer").Cells(1, 255), ActivePrinter:=print3,
Collate:=True
If CheckBox1.Value = False And CheckBox2.Value = False And
CheckBox3.Value = False Then ActiveWindow.SelectedSheets.PrintOut From:=1,
to:=1, Copies:=Sheets("Leer").Cells(1, 255), Collate:=True
GoTo ende
ende:
ActiveSheet.PageSetup.CenterFooter = ""
Sheets("Leer").Cells(1, 255) = ""
Sheets("Leer").Cells(99, 255) = ""
abbruch:
Sheets("Leer").Cells(100, 100) = ""
Sheets("Leer").Cells(101, 100) = ""
Sheets("Leer").Cells(110, 110) = ""
Sheets("Leer").Cells(111, 111) = ""
Sheets("Leer").Cells(112, 112) = ""
update_ein ' Aktualisierung ein
Unload Me
ende1:
End Sub
Wie kann ich das vereinfachen?
Denn ich speichere viele Daten in der Datei zwischen.
Gruß
Karsten J.