PDA

View Full Version : Adjust the CurrentRegion when copying



NewDaddy
02-14-2008, 08:27 AM
Hi All

I am looping through excel workbooks (monthly transaction reports) in a folder, extracting data based on certain criteria (using the autofilter) and using the currentregion property copying that data to my main workbook so I end up with transactions for all months that meet the criteria in 1 worksheet. (see extract below)



Cells.CurrentRegion.Copy Destination:=aBook.Range("A1").Offset(x, 0)
x = aBook.UsedRange.Rows.Count



What I would like help with is 'adjusting' the currentregion so I am not copying row1 of the current region (i.e. the title row), but from row 2 down, how can I do this?

Thanks

Bob Phillips
02-14-2008, 08:43 AM
One very simple way



Intersect(Cells.CurrentRegion, Rows("2:" & Cells.CurrentRegion.Count - 1))

NewDaddy
02-14-2008, 08:46 AM
xld

Again you have come to my rescue. Many thanks.

Bob Phillips
02-14-2008, 11:10 AM
Whilst the code that I gave you does work, it should have been



Intersect(Cells.CurrentRegion, Rows("2:" & Cells.CurrentRegion.Rows.Count)).Address