Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all articles
Browse latest Browse all 88066

Correct way to offset headers while looping through a filtered list?

$
0
0

In the below code i'm trying to use a for loop through a filtered list. Without the offset the loop is going through each field and copying the data multiple times. With the offset its skipping rows.

How can I rephrase this to only loop through each row once, and skip the header row?

'Offset Placement Wrong
        Set rngVisible = activeSheet.AutoFilter.Range.SpecialCells(xlCellTypeVisible).Offset(1, 0)

        For Each rngCell In rngVisible

                    Rows(rngCell.Row).Select
                    Selection.Copy

                    Sheets(2).Select

                    'Skip Headers
                    Cells(2 + rowsRelocated, 1).Select
                    activeSheet.Paste

                    Sheets(1).Select

                    'row increment
                    rowsRelocated = rowsRelocated + 1

         Next

Viewing all articles
Browse latest Browse all 88066

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>