Excel 避免在可见范围内粘贴副本

Excel 避免在可见范围内粘贴副本,excel,vba,Excel,Vba,我希望通过简单地引用其他范围来避免代码中的复制粘贴 VisibleRowsCount = Application.WorksheetFunction.Subtotal(3, Range(FromTable & "[" & FlagColumn & "]")) Dim DestinationRange As Range, SourceRange As Range Set DestinationRange = Sheets("Sht1").ListObj

我希望通过简单地引用其他范围来避免代码中的复制粘贴

   VisibleRowsCount = Application.WorksheetFunction.Subtotal(3, Range(FromTable & "[" & FlagColumn & "]"))

   Dim DestinationRange As Range, SourceRange As Range

   Set DestinationRange = Sheets("Sht1").ListObjects(ToTable).ListColumns(ColumnSplit(0)).Range
   Set SourceRange = Sheets("Sht2").ListObjects(FromTable).ListColumns(ColumnSplit(1)).DataBodyRange.SpecialCells(xlCellTypeVisible)

   DestinationRange.Cells(lastCell, 1).Resize(SourceRange.Count, 1).Value = SourceRange
我得到了正确的新行数,但所有值都只等于可见范围的第一行


如果需要了解的话,我会使用ListObjects列作为目标和源范围。

SourceRange.Range.SpecialCells(xlCellTypeVisible)
看起来不正确。我想我们需要更多信息。他们是如何定义DestinationRange、VisibleRowsCount和SourceRange的?根据VisibleRowsCount的工作方式,它们不会在筛选范围内工作。检查添加的更多代码您可以添加更多代码以便我们可以使用吗?