eine kurze Frage: Ich habe bei meier Tabelle ein Makro drin, der automatisch die Summe bis zu letzten Zeile errechnet. Jetzt habe ich vor diesen Code verschiedene Filter geschaltet, so das natürlich nur die Zeilen mitberechnet werden die auch eingeblendet sind.
Jedoch rechnet mein Code immer mit allen aus und eingeblendeten Zeilen. Kann mir einer helfen wie ich nur die eingeblendeten Zeilen miteinbeziehe?
Das hier ist mein Code:
Sub MySum()
Dim lnglast As Long
Application.ScreenUpdating = False
With Sheets("Parts")
lnglast = Cells(Rows.Count, 1).End(xlUp).Row
If Cells(lnglast, 1) = "Gesamtsumme" Then
Sheets("Parts").Rows(lnglast).Delete
Cells(lnglast, 1) = "Gesamtsumme"
Cells(lnglast, 181) = Application.Sum(Range(Cells(2, 181), Cells(lnglast, 181)))
Cells(lnglast, 182) = Application.Sum(Range(Cells(2, 182), Cells(lnglast, 182)))
Cells(lnglast, 183) = Application.Sum(Range(Cells(2, 183), Cells(lnglast, 183)))
Cells(lnglast, 184) = Application.Sum(Range(Cells(2, 184), Cells(lnglast, 184)))
Cells(lnglast, 185) = Application.Sum(Range(Cells(2, 185), Cells(lnglast, 185)))
Cells(lnglast, 186) = Application.Sum(Range(Cells(2, 186), Cells(lnglast, 186)))
Cells(lnglast, 187) = Application.Sum(Range(Cells(2, 187), Cells(lnglast, 187)))
Cells(lnglast, 188) = Application.Sum(Range(Cells(2, 188), Cells(lnglast, 188)))
Cells(lnglast, 189) = Application.Sum(Range(Cells(2, 189), Cells(lnglast, 189)))
Cells(lnglast, 190) = Application.Sum(Range(Cells(2, 190), Cells(lnglast, 190)))
Cells(lnglast, 191) = Application.Sum(Range(Cells(2, 191), Cells(lnglast, 191)))
Cells(lnglast, 192) = Application.Sum(Range(Cells(2, 192), Cells(lnglast, 192)))
Else
Cells(lnglast + 1, 1) = "Gesamtsumme"
Cells(lnglast + 1, 181) = Application.Sum(Range(Cells(2, 181), Cells(lnglast, 181)))
Cells(lnglast + 1, 182) = Application.Sum(Range(Cells(2, 182), Cells(lnglast, 182)))
Cells(lnglast + 1, 183) = Application.Sum(Range(Cells(2, 183), Cells(lnglast, 183)))
Cells(lnglast + 1, 184) = Application.Sum(Range(Cells(2, 184), Cells(lnglast, 184)))
Cells(lnglast + 1, 185) = Application.Sum(Range(Cells(2, 185), Cells(lnglast, 185)))
Cells(lnglast + 1, 186) = Application.Sum(Range(Cells(2, 186), Cells(lnglast, 186)))
Cells(lnglast + 1, 187) = Application.Sum(Range(Cells(2, 187), Cells(lnglast, 187)))
Cells(lnglast + 1, 188) = Application.Sum(Range(Cells(2, 188), Cells(lnglast, 188)))
Cells(lnglast + 1, 189) = Application.Sum(Range(Cells(2, 189), Cells(lnglast, 189)))
Cells(lnglast + 1, 190) = Application.Sum(Range(Cells(2, 190), Cells(lnglast, 190)))
Cells(lnglast + 1, 191) = Application.Sum(Range(Cells(2, 191), Cells(lnglast, 191)))
Cells(lnglast + 1, 192) = Application.Sum(Range(Cells(2, 192), Cells(lnglast, 192)))
End If
End With
End Sub
Liebe Grüße und vielen Dank,Manuel