G
Guest
Good morning all,
I'm using VBA loop to repeatedly filter a database based on the contents of
a list of cells containing employee names.
Once I filter on a particular name, I end up with (say) a header row and
5-10 rows of data underneath.
I then want to copy the data rows (but not the header row) into another
workbook.
I've been trying to use CurrentRegion, then offsetting this selection by 1
and resizing by the number of rows in the currentselection minus 1 to exclude
the header rows and select the data rows thus:
Set EFCR = Range("A4").CurrentRegion
EFCR.Offset(1, 0).Resize(EFCR.Rows.Count - 1, EFCR.Columns.Count).Copy
The problem I have is that Currentregion includes all the hidden date rows
that have been excluded by the filter, so I can't use it to select my data.
There may be only 10 rows visible, but Currentregion returns the size of the
whole database.
I think I need some combination of CurrentRegion and xlCellTypeVisible to
accomplish what I need, but I'm not sure if this is possible, or, if it is,
what the syntax should be. Otherwise, the alternative is a very nasty
For-Next loop for every crow in the database. Ugly.
Can anyone help, please?
Thanks in advance
Pete
I'm using VBA loop to repeatedly filter a database based on the contents of
a list of cells containing employee names.
Once I filter on a particular name, I end up with (say) a header row and
5-10 rows of data underneath.
I then want to copy the data rows (but not the header row) into another
workbook.
I've been trying to use CurrentRegion, then offsetting this selection by 1
and resizing by the number of rows in the currentselection minus 1 to exclude
the header rows and select the data rows thus:
Set EFCR = Range("A4").CurrentRegion
EFCR.Offset(1, 0).Resize(EFCR.Rows.Count - 1, EFCR.Columns.Count).Copy
The problem I have is that Currentregion includes all the hidden date rows
that have been excluded by the filter, so I can't use it to select my data.
There may be only 10 rows visible, but Currentregion returns the size of the
whole database.
I think I need some combination of CurrentRegion and xlCellTypeVisible to
accomplish what I need, but I'm not sure if this is possible, or, if it is,
what the syntax should be. Otherwise, the alternative is a very nasty
For-Next loop for every crow in the database. Ugly.
Can anyone help, please?
Thanks in advance
Pete