![]() |
Copy last 12 rows after filtering
I need to filter some data based on a specific field. However, I need to copy
only the last 12 rows of the filtered data and paste it on another worksheet. I know how to do all of this in VB except for determining how to only capture the last 12 rows of the filtered data. I tried getting the last column of data and setting the copy range from [(last row - 12) to last row] but this gets the hidden and visible rows instead of 12 of the visible rows. For ex. lets assume the filtered data is on rows 1,5,10,15,16,24,28,35,40,42,60,72, 75,80. I only need the last 12 so I need rows 10 ... 80. If I use (last row-12) then it "copies" rows 68 - 80 but really only captures the data on rows 72 and 80 since the other data between rows 68 and 80 are hidden. How can I accomplish this? |
Copy last 12 rows after filtering
Get the last row of the destination sheet before you copy to it, then
get it again after you've copied to it to determine how many rows were copied, then delete all but the last 12 in the destination sheet. Charles RW wrote: I need to filter some data based on a specific field. However, I need to copy only the last 12 rows of the filtered data and paste it on another worksheet. I know how to do all of this in VB except for determining how to only capture the last 12 rows of the filtered data. I tried getting the last column of data and setting the copy range from [(last row - 12) to last row] but this gets the hidden and visible rows instead of 12 of the visible rows. For ex. lets assume the filtered data is on rows 1,5,10,15,16,24,28,35,40,42,60,72, 75,80. I only need the last 12 so I need rows 10 ... 80. If I use (last row-12) then it "copies" rows 68 - 80 but really only captures the data on rows 72 and 80 since the other data between rows 68 and 80 are hidden. How can I accomplish this? |
Copy last 12 rows after filtering
This may be a good approach to my problem. Thanks
"Die_Another_Day" wrote: Get the last row of the destination sheet before you copy to it, then get it again after you've copied to it to determine how many rows were copied, then delete all but the last 12 in the destination sheet. Charles RW wrote: I need to filter some data based on a specific field. However, I need to copy only the last 12 rows of the filtered data and paste it on another worksheet. I know how to do all of this in VB except for determining how to only capture the last 12 rows of the filtered data. I tried getting the last column of data and setting the copy range from [(last row - 12) to last row] but this gets the hidden and visible rows instead of 12 of the visible rows. For ex. lets assume the filtered data is on rows 1,5,10,15,16,24,28,35,40,42,60,72, 75,80. I only need the last 12 so I need rows 10 ... 80. If I use (last row-12) then it "copies" rows 68 - 80 but really only captures the data on rows 72 and 80 since the other data between rows 68 and 80 are hidden. How can I accomplish this? |
All times are GMT +1. The time now is 06:16 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com