Wer Kann mir helfen ich weiß nicht wo der Fehler ist.
Ich habe mir durch eurer Hilfe ein Makro zusammengebastelt mit dem ich wenn ich mehr als Zwei Seiten Habe einen Übertrag erstelle und am ende Nettosumme und Gesammtsuzmme erstelle.
Nun zu Meinem Problem wenn ich ich nur eine Rechnungsseite Habe klappt alles hundertprozentig ( Goto ENDE: )aber wenn ich mhr als eine Rechnungsseite Habe, dann führt er das Makro oder einen Teil immer Zwei malDurch.Der Teil der immer zwei mal kommt ist der mit den userformen . Woran liegt das wo ist der Fehler bin für jeden Lösungsvorschlag Dankbar
Sub Bild7_BeiKlick()
Range("f65536").End(xlUp).Offset(1, 0).Select
Cells(ActiveCell.Row + 1, 4).Formula = " Nettobetrag:"
Cells(ActiveCell.Row + 1, 4).HorizontalAlignment = xlRight
Cells(ActiveCell.Row + 1, 5).Formula = "EURO"
Cells(ActiveCell.Row + 1, 5).HorizontalAlignment = xlRight
Cells(ActiveCell.Row + 2, 4).Formula = " MwSt:"
Cells(ActiveCell.Row + 2, 4).HorizontalAlignment = xlRight
Cells(ActiveCell.Row + 2, 5).Formula = "EURO"
Cells(ActiveCell.Row + 2, 5).HorizontalAlignment = xlRight
Cells(ActiveCell.Row + 1, 6).Formula = "=Sum(" & ActiveCell.Offset(0, 0).Address & ":f19)"
Cells(ActiveCell.Row + 4, 5).Formula = "EURO"
Cells(ActiveCell.Row + 4, 5).HorizontalAlignment = xlRight
Cells(ActiveCell.Row + 4, 4).Select
With Selection
.MergeCells = True
End With
ActiveCell.Formula = "Gesammtbetrag:"
ActiveCell.HorizontalAlignment = xlRight
Range(Cells(ActiveCell.Row - 2, 6), Cells(ActiveCell.Row - 2, 6)).Select
ActiveCell.FormulaR1C1 = "=R[-1]C*0.16"
Range(Cells(ActiveCell.Row + 2, 6), Cells(ActiveCell.Row + 2, 6)).Select
ActiveCell.FormulaR1C1 = "=R[-3]C+R[-2]"
Dim varPB As Variant
Dim iPage As Integer, iRowL As Integer
iRowL = Cells(Rows.Count, 1).End(xlUp).Row
iPage = 1
Do While IsError(varPB) = False
varPB = ExecuteExcel4Macro("INDEX(GET.DOCUMENT(64)," & iPage & ")")
If IsError(varPB) Then
GoTo ENDE
Exit Sub
Else
Rows(varPB - 1 & ":" & varPB + 3).Insert Shift:=xlDown
Range("A18:F18").Copy Destination:=Cells(varPB + 3, 1)
Range(Cells(varPB - 1, 5), Cells(varPB - 1, 6)).Select
With Selection
.MergeCells = True
End With
Cells(varPB - 1, 4) = "Übertrag"
Cells(varPB - 1, 5) = Application.Sum(Range(Cells(1, 6), _
Cells(varPB - 1, 6)))
Range(Cells(varPB + 1, 5), Cells(varPB + 1, 6)).Select
With Selection
.MergeCells = True
End With
Cells(varPB + 1, 4) = "Übertrag"
Cells(varPB + 1, 5) = Application.Sum(Range(Cells(1, 6), _
Cells(varPB - 1, 6)))
End If
iPage = iPage + 1
Dim Qe
ENDE:
Userform3.Show
UserForm1.Show
'Vorschau vor dem Druck
ActiveWindow.SelectedSheets.PrintPreview
UserForm2.Show
Loop
End Sub