问题
First my source looks like this:
I want the 2 sub-ranges (let's say "A3:C6" & "A8:C11") to be pasted on one powerpoint slide side by side. This is for one worksheet. There are 6 such sheets all with same range.
I learnt how to use PageSetup
property to change object dimensions (code posted here) but i'm not able to write a for
loop to paste each sub-range to each corner of a slide. And extend that for
loop to all 6 sheets in my workbook. Can anyone help me please?
回答1:
This is a generalized solution: You have to add sheet names in mySheet array below and also you have to add range names to the myRange array below:
Sub stackOverflow()
Dim myRange(1 To 12) As String
Dim mySheet(1 To 6) As Worksheet
myRange(1) = "A3:C6"
''Define all ranges like above line
Set mySheet(1) = ThisWorkbook.Worksheets("Sheet1")
''Define all sheets like above line
j = 1
For i = 1 To 6
mySheet(i).range(myRange(j)).Copy
''code to paste range in powerpoint
j = j + 1
mySheet(i).range(myRange(j)).Copy
''code to paste range in powerpoint
j = j + 1
Next i
End Sub
来源:https://stackoverflow.com/questions/61022610/copy-excel-ranges-onto-same-slide-in-powerpoint-as-adjacent-pictures