Ich habe eine Frage zu Visual Basic Das Problem ist die Bezeichnung von ("PivotTable2") Ich will das es egal ist, welche Nummer dahinter steht?
("PivotTable1") =("PivotTable2") =("PivotTable3") =("PivotTable4") =("PivotTable5")
MÜSSTE in diesem Forum für niemanden ein Problem sein. Trotzdem bedanke ich mich für die Hilfe
Spoiler anzeigen
EDIT: Bitte Code-Tags verwenden. Lange Quelltext bitte in Spoilern verpacken. Keine Doppelpostings erstellen. ~fufu
("PivotTable1") =("PivotTable2") =("PivotTable3") =("PivotTable4") =("PivotTable5")
MÜSSTE in diesem Forum für niemanden ein Problem sein. Trotzdem bedanke ich mich für die Hilfe
VB.NET-Quellcode
- Sub PivotTableForm()
- '
- ' PivotTableForm Makro
- '
- '
- With ActiveSheet.PivotTables("PivotTable2").PivotFields("SP")
- .Orientation = xlColumnField
- .Position = 1
- End With
- ActiveSheet.PivotTables("PivotTable2").AddDataField ActiveSheet.PivotTables( _
- "PivotTable2").PivotFields("ProdNr"), "Summe von ProdNr", xlSum
- With ActiveSheet.PivotTables("PivotTable2").PivotFields("Folgeknoten")
- .Orientation = xlRowField
- .Position = 1
- End With
- ActiveSheet.PivotTables("PivotTable2").PivotSelect "'Row Grand Total'", _
- xlDataAndLabel, True
- Range("D4").Select
- ActiveSheet.PivotTables("PivotTable2").GrandTotalName = "Gesamt"
- Range("C4").Select
- ActiveSheet.PivotTables("PivotTable2").PivotFields("SP").PivotItems("(blank)"). _
- Caption = "Frei"
- Range("B3").Select
- ActiveSheet.PivotTables("PivotTable2").CompactLayoutColumnHeader = ""
- Range("B4").Select
- ActiveSheet.PivotTables("PivotTable2").PivotSelect "", xlDataAndLabel, True
- Selection.Borders(xlDiagonalDown).LineStyle = xlNone
- Selection.Borders(xlDiagonalUp).LineStyle = xlNone
- With Selection.Borders(xlEdgeLeft)
- .LineStyle = xlContinuous
- .ColorIndex = 0
- .TintAndShade = 0
- .Weight = xlThin
- End With
- With Selection.Borders(xlEdgeTop)
- .LineStyle = xlContinuous
- .ColorIndex = 0
- .TintAndShade = 0
- .Weight = xlThin
- End With
- With Selection.Borders(xlEdgeBottom)
- .LineStyle = xlContinuous
- .ColorIndex = 0
- .TintAndShade = 0
- .Weight = xlThin
- End With
- With Selection.Borders(xlEdgeRight)
- .LineStyle = xlContinuous
- .ColorIndex = 0
- .TintAndShade = 0
- .Weight = xlThin
- End With
- With Selection.Borders(xlInsideVertical)
- .LineStyle = xlContinuous
- .ColorIndex = 0
- .TintAndShade = 0
- .Weight = xlThin
- End With
- With Selection.Borders(xlInsideHorizontal)
- .LineStyle = xlContinuous
- .ColorIndex = 0
- .TintAndShade = 0
- .Weight = xlThin
- End With
- With Selection.Font
- .Name = "Calibri"
- .Size = 14
- .Strikethrough = False
- .Superscript = False
- .Subscript = False
- .OutlineFont = False
- .Shadow = False
- .Underline = xlUnderlineStyleNone
- .ThemeColor = xlThemeColorLight1
- .TintAndShade = 0
- .ThemeFont = xlThemeFontMinor
- End With
- Columns("A:A").EntireColumn.AutoFit
- Cells.Select
- Cells.EntireColumn.AutoFit
- Range("C6").Select
- ActiveSheet.PivotTables("PivotTable2").PivotFields("Summe von ProdNr"). _
- Function = xlCount
- Range("D5").Select
- ActiveWindow.View = xlPageLayoutView
- Application.PrintCommunication = False
- With ActiveSheet.PageSetup
- .LeftHeader = ""
- .CenterHeader = ""
- .RightHeader = "&U &D"
- .LeftFooter = ""
- .CenterFooter = ""
- .RightFooter = ""
- .LeftMargin = Application.InchesToPoints(0.7)
- .RightMargin = Application.InchesToPoints(0.7)
- .TopMargin = Application.InchesToPoints(0.787401575)
- .BottomMargin = Application.InchesToPoints(0.787401575)
- .HeaderMargin = Application.InchesToPoints(0.3)
- .FooterMargin = Application.InchesToPoints(0.3)
- .Zoom = 100
- .PrintErrors = xlPrintErrorsDisplayed
- .OddAndEvenPagesHeaderFooter = False
- .DifferentFirstPageHeaderFooter = False
- .ScaleWithDocHeaderFooter = True
- .AlignMarginsHeaderFooter = True
- .EvenPage.LeftHeader.Text = ""
- .EvenPage.CenterHeader.Text = ""
- .EvenPage.RightHeader.Text = ""
- .EvenPage.LeftFooter.Text = ""
- .EvenPage.CenterFooter.Text = ""
- .EvenPage.RightFooter.Text = ""
- .FirstPage.LeftHeader.Text = ""
- .FirstPage.CenterHeader.Text = ""
- .FirstPage.RightHeader.Text = ""
- .FirstPage.LeftFooter.Text = ""
- .FirstPage.CenterFooter.Text = ""
- .FirstPage.RightFooter.Text = ""
- End With
- Application.PrintCommunication = True
- ActiveWindow.SmallScroll Down:=24
- Application.PrintCommunication = False
- With ActiveSheet.PageSetup
- .LeftHeader = ""
- .CenterHeader = ""
- .RightHeader = "&U &D"
- .LeftFooter = ""
- .CenterFooter = ""
- .RightFooter = "&N"
- .LeftMargin = Application.InchesToPoints(0.7)
- .RightMargin = Application.InchesToPoints(0.7)
- .TopMargin = Application.InchesToPoints(0.787401575)
- .BottomMargin = Application.InchesToPoints(0.787401575)
- .HeaderMargin = Application.InchesToPoints(0.3)
- .FooterMargin = Application.InchesToPoints(0.3)
- .Zoom = 100
- .PrintErrors = xlPrintErrorsDisplayed
- .OddAndEvenPagesHeaderFooter = False
- .DifferentFirstPageHeaderFooter = False
- .ScaleWithDocHeaderFooter = True
- .AlignMarginsHeaderFooter = True
- .EvenPage.LeftHeader.Text = ""
- .EvenPage.CenterHeader.Text = ""
- .EvenPage.RightHeader.Text = ""
- .EvenPage.LeftFooter.Text = ""
- .EvenPage.CenterFooter.Text = ""
- .EvenPage.RightFooter.Text = ""
- .FirstPage.LeftHeader.Text = ""
- .FirstPage.CenterHeader.Text = ""
- .FirstPage.RightHeader.Text = ""
- .FirstPage.LeftFooter.Text = ""
- .FirstPage.CenterFooter.Text = ""
- .FirstPage.RightFooter.Text = ""
- End With
- Application.PrintCommunication = True
- Range("E40").Select
- ActiveWindow.SmallScroll Down:=-39
- End Sub
EDIT: Bitte Code-Tags verwenden. Lange Quelltext bitte in Spoilern verpacken. Keine Doppelpostings erstellen. ~fufu
Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von „fufu“ ()