I have these two for loops that are trying to create slides for a powerpoint presentation but one is suppose to find and store specific ranges of cells that are referencing a PivotTable
This one is trying to find the ranges of the tables in the excel file in one worksheet and actually store them in an array of 40 elements (redim RngGroup(1 to 40))
‘Find table range
For Each foundCell In ActiveSheet.UsedRange.Cells
If Not IsEmpty(foundCell) Then
control = foundCell.Value
If control = "Values" Then
stRow = foundCell.Row
End If
If control = "Grand Total" Then
endRow = foundCell.Row
Else
GoTo Line1
End If
Else
GoTo Line1
End If
Set RngGroup(i) = Range(Cells(stRow, 1), Cells(endRow, 5))
i = i + 1
Line1:
Next foundCell
And this one trying to create slides for the Tables and charts
For Each Chrt In ActiveSheet.ChartObjects
'Adding slide for table
Set PPTSlide = PPTPres.Slides.Add(SIndex, ppLayoutCustom)
Set TbRange = RngGroup(i)
TbRange.Copy
PPTSlide.Shapes.Paste
i = i + 1
'Copy chart
Chrt.Copy
'Create slide, set layout to custom
Set PPTSlide = PPTPres.Slides.Add(SIndex + 1, ppLayoutCustom)
PPTSlide.Shapes.Paste
'Increment index value
SIndex = SIndex + 2
Next Chrt
Leonardo Hobeni is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.