我有一个数据表。我应用自动过滤器。现在,我只想复制并粘贴该可见数据。我正在使用命令UsedRange.SpecialCells(xlCellTypeVisible).Copy,现在可以使用了。还有其他方法吗?或解决方法?
这是我的代码
ws1.Activate
ws1.Cells(1, 1).Select
'to count how many lines are on the sheet
LastRow = ws1.Range("A1").CurrentRegion.Rows.Count
'lets use the last row to build the range that I need to filter
myrange = CStr(LastRow)
'I filter the range on the sheet by 0.14
ws1.Range("A1:O" & myrange).AutoFilter Field:=8, Criteria1:="0.14"
'this counts the data(rows) visible after applying the filter and -1 means minus the header
Rowz = ws1.AutoFilter.Range.Columns(1).SpecialCells(xlCellTypeVisible).Cells.Count - 1
'this will copy the filtered data into the following range
'I get the error in this line of code. dont know what wrong
ws1.UsedRange.SpecialCells(xlCellTypeVisible).Copy Range("A" & CStr(LastRow + 1) & ":O" & CStr(LastRow + 1))
'I tried as well
ws1.UsedRange.SpecialCells(xlCellTypeVisible).Copy Range("A" & CStr(LastRow + 1) & ":O" & CStr(LastRow + 1 + Rowz))
欢迎任何想法:)