Hi all,
I have been working on the following code to copy paste the following:
- grab the header (Row 1)
- grab each group of data in pairs of 5 (Row 2-6, 7-11, 12-16, etc.)
- paste into Powerpoint slide
I have written the following so far:
'grab header row
Set head = ThisWorkbook.ActiveSheet.Range(Cells(1, "A"), Cells(1, "C"))
'loop through each data
For i = 2 To last Step 5
Set rng = ThisWorkbook.ActiveSheet.Range(Cells(i, "A"), Cells(i + 4, "C"))
Set rng = Union(head, rng)
'Copy Excel Range
rng.Copy
'Create new slide
Set mySlide = myPresentation.Slides.Add(1, 11) '11 = ppLayoutTitleOnly mySlide.Shapes.PasteSpecial DataType:=2 '2 = ppPasteEnhancedMetafile
Next i
Problem: What this is doing is looping through the data, grabbing the header and the 5 rows of data. Then on the next loop, it keeps the previous set of data and copies and pastes the next set of data, so I have 10 rows of data instead of 5.
Can you help explain why my code is not copying the next set of data? It seems like it still recognizes "i" as 2, while only "i+4" is iterative. I have already tried clearing the clipboard with the "Application.CutCopyMode = False" method, but that did not help.
Thanks for any suggestions.
I have been working on the following code to copy paste the following:
- grab the header (Row 1)
- grab each group of data in pairs of 5 (Row 2-6, 7-11, 12-16, etc.)
- paste into Powerpoint slide
I have written the following so far:
'grab header row
Set head = ThisWorkbook.ActiveSheet.Range(Cells(1, "A"), Cells(1, "C"))
'loop through each data
For i = 2 To last Step 5
Set rng = ThisWorkbook.ActiveSheet.Range(Cells(i, "A"), Cells(i + 4, "C"))
Set rng = Union(head, rng)
'Copy Excel Range
rng.Copy
'Create new slide
Set mySlide = myPresentation.Slides.Add(1, 11) '11 = ppLayoutTitleOnly mySlide.Shapes.PasteSpecial DataType:=2 '2 = ppPasteEnhancedMetafile
Next i
Problem: What this is doing is looping through the data, grabbing the header and the 5 rows of data. Then on the next loop, it keeps the previous set of data and copies and pastes the next set of data, so I have 10 rows of data instead of 5.
Can you help explain why my code is not copying the next set of data? It seems like it still recognizes "i" as 2, while only "i+4" is iterative. I have already tried clearing the clipboard with the "Application.CutCopyMode = False" method, but that did not help.
Thanks for any suggestions.