转置粘贴复制范围从Excel到PowerPoint图表

我正在尝试使用Excel中的数据更新一些幻灯片,并使用下面的代码将其粘贴到PowerPoint Chart后端。

Sub updateSlides() Application.DisplayAlerts = False Dim xlApp, xlWorkBook, xlSheet As Object Set xlApp = CreateObject("Excel.Application") ' Not transposing xlApp.DisplayAlerts = Flase xlApp.Visible = True Set xlWorkBook = xlApp.Workbooks.Open("ExcelFilePath") Set xlSheet = xlWorkBook.Sheets("SheetName") For i = 1 To 9 With ActivePresentation.Slides(i) Set charts = .Shapes("Chart 37").Chart.ChartData charts.Activate Set chartData = charts.Workbook.Sheets("Sheet1") xlSheet.Range(xlSheet.Cells(2 + i, 2), xlSheet.Cells(2 + i, 3)).copy chartData.Range("B8").PasteSpecial Paste:=-4163 ' I need to transpose the copied data here' charts.Workbook.Close End With If i < 9 Then ActiveWindow.View.GotoSlide Index:=ActiveWindow.Selection.SlideRange.Duplicate.SlideIndex End If Next i xlApp.Quit xlApp.DisplayAlerts = True Set xlApp = Nothing ' ActivePresentation.Save Application.DisplayAlerts = True End Sub 

在第20行,我需要转置复制的数据并将其粘贴到提供的目标范围。 任何帮助,非常感激。

尝试使用Transpose参数:

 chartData.Range("B8").PasteSpecial Paste:=-4163, Transpose:=True 

还纠正错字:

 xlApp.DisplayAlerts = False ' <--- Not Flase