向数组元素添加过滤

时间:2019-03-26 14:06:58

标签: excel vba

我想将具有一定范围的Excel工作表添加到VBA数组并对其应用过滤。然后,我将其作为图片打印到PowerPoint。如何在MyRangeArray数组中应用Range.AutoFilter方法?

'Create a New Presentation
Set myPresentation = PowerPointApp.ActivePresentation

'List of PPT Slides to Paste to
MySlideArray = Array(2, 3, 4, 5, 6, 7)

'List of Excel Ranges to Copy from
    MyRangeArray = Array(Sheet1.Range("A6:P28"), _
    Sheet4.Range("B6:P17"), _
    Sheet6.Range("B6:P16"), _
    Sheet9.Range("C6:P15"), _
    Sheet11.Range("B6:P14"), _
    Sheet16.Range("B6:P14"))

'Loop through Array data
 For x = LBound(MySlideArray) To UBound(MySlideArray)
   'Copy Excel Range
      MyRangeArray(x).CopyPicture

 'Paste to PowerPoint and position
  On Error Resume Next
    Set shp = myPresentation.Slides(MySlideArray(x)).Shapes.PasteSpecial
  On Error GoTo 0

  With myPresentation.PageSetup
  'Lock Aspect Ratio
    shp.LockAspectRatio = msoTrue

  'Assign Height Width
    shp.Height = 11.16 * 28.3465
    shp.Width = 23.88 * 28.3465

  'Assign Position
    shp.Left = 0.75 * 28.3465
    shp.Top = 2.7 * 28.3465 ' 28.3465 points=1cm         
  End With    
Next x

我希望将过滤器应用于选定工作表中选定范围的单元格。

0 个答案:

没有答案