Copy excel ranges onto same slide in powerpoint as adjacent pictures

家住魔仙堡 提交于 2020-04-16 05:47:07

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!