我使用变量引用来选择循环中的过滤范围,并且在范围引用变得相同时有一些困难时间。当它变得相同时,代码选择整张纸。我无法解决这个问题。 这里是我的代码范围(单元格)。可选单元格选择整个工作表
For tor = 11 To 17 ' for selecting the column
.UsedRange.AutoFilter Field:=tor, Criteria1:="Yes"
coot = .Cells(.Rows.Count, 1).End(xlUp).Row
If coot > 1 Then ' stuck here when coot becomes 2 code is selecting the whole sheet
Set yesrng = .Range(Cells(2, tor), Cells(coot,tor)).SpecialCells(xlCellTypeVisible)
yesrng.Select
end if
Next tor
你能提供一张工作表的快照吗?这将有助于理解这个问题更多 – Zac
@Zac图片按照请求添加。 – Neelesh
顶部有隐藏的行吗? – Zac