o0omax
09-08-2021, 03:20 AM
hello I have a Problem with my Sub MoveAndEdit.
I try to call it in my previous Sub but somehow it doesnt work. Does somebody has an solution?
My goal is to move and edit all the Diagrams I creted in the first Sub.
Sub DiagrammErstellen()
Dim DL As Integer '#Zeilen
Dim i As Integer ' Zeilen Laufindex
Dim sheet As Worksheet
Set MyWorksheet = ThisWorkbook.Sheets("KPI")
Application.CutCopyMode = False
DL = Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To DL
With MyWorksheet.Shapes.AddChart2(216, xlBarClustered).Chart
.ChartArea.ClearContents
.SeriesCollection.NewSeries
With .FullSeriesCollection(1)
.Name = "=Pivot! " & Cells(i, 1).Address
.Values = "=Pivot!" & Range(Cells(i, 2), Cells(i, 3)).Address
End With
Call MoveAndEdit
'.HasLegend = False
End With
Next i
End Sub
Sub MoveAndEdit()
With ActiveChart
.Width = 10
.Height = 10
.Top = Cells(i, 2).Top
.Left = Cells(i, 2).Top
End With
End Sub
I try to call it in my previous Sub but somehow it doesnt work. Does somebody has an solution?
My goal is to move and edit all the Diagrams I creted in the first Sub.
Sub DiagrammErstellen()
Dim DL As Integer '#Zeilen
Dim i As Integer ' Zeilen Laufindex
Dim sheet As Worksheet
Set MyWorksheet = ThisWorkbook.Sheets("KPI")
Application.CutCopyMode = False
DL = Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To DL
With MyWorksheet.Shapes.AddChart2(216, xlBarClustered).Chart
.ChartArea.ClearContents
.SeriesCollection.NewSeries
With .FullSeriesCollection(1)
.Name = "=Pivot! " & Cells(i, 1).Address
.Values = "=Pivot!" & Range(Cells(i, 2), Cells(i, 3)).Address
End With
Call MoveAndEdit
'.HasLegend = False
End With
Next i
End Sub
Sub MoveAndEdit()
With ActiveChart
.Width = 10
.Height = 10
.Top = Cells(i, 2).Top
.Left = Cells(i, 2).Top
End With
End Sub