I have a excel table with a autofilter.
In the filtered table i only have few rows filtered.
My objective is icterate all visible rows to colect data to copy to anothe sheet.
I want a way to collect a variable with the the fisrt visible row number.
my draft code is:
Dim cnp As String
Dim nome As String
Dim filter_rng As Range
Dim rw As Range
Dim last_row As Long 'last visible data row
Dim dest_row As Long 'row to paste the colected data
Set filter_rng = Range("A5:Y" & last_row).Rows.SpecialCells(xlCellTypeVisible)
'collect data
For Each rw In filter_rng.SpecialCells(xlCellTypeVisible)
workshett(1).Activate
cnp = Range("a" & rw).Value
nome = Range("b" & rw).Value
'copy data to another worksheet first data line is cell A2
Worksheet(2).Activate
Range("A" & dest_row + 1).Value = cnp
Range("b" & dest_row + 1).Value = nome
Next rw