I need to filter some data based on duration (column) and copy the ids (other column) of the result to another sheet.
I have tried the following, but I always get 1 as the amount of filtered rows (actually it's over 100) and an error on the copy attempt:
dataSheet.UsedRange.AutoFilter Field:=durationColIndex, Criteria1:="<100"
Dim quickRange As Range, quickCount As Long
Set quickRange = dataSheet.UsedRange.SpecialCells(xlCellTypeVisible)
quickCount = quickRange.Rows.Count '<----- does not work, is always 1
If quickCount > 0 Then
Set specialIdsSheet = Sheets.Add 'defined before
'copy col 1
quickRange.Range(Cells(1, idIndex), Cells(25, idIndex)).Copy '<-- other issue. 25 to substitue the not working quickCount
specialIdsSheet.Cells(1, 1).PasteSpecial
End If
I have tried to work around it for some hours now, but I stuck and don't understand why it is not working. I had a solution before that was using ActiveSheet and Select, but I wanted to move away from that.
ActiveSheet.Range("A1").CurrentRegion.Range(Cells(1, idIndex), Cells(ActiveCell.CurrentRegion.Rows.Count, idIndex)).Select
Selection.Copy
Sheets.Add After:=ActiveSheet
Thanks in advance!