Copy does not get last visible row

James Snyder

Well-known Member
Joined
Jan 11, 2013
Messages
618
I am losing the last row of data when using '.SpecialCells(xlCellTypeVisible).Copy'. Since this is not a range I set, I am wondering if others have found this and have a workaround. Below are links to screenshots showing the problem:
Losing NULLs 1 - Bermex's library
Losing NULLs 2 - Bermex's library
Losing NULLs 3 - Bermex's library

Code:
            With ftpWkSht
                ' If we have a valid workbook and a valid worksheet, find the bottom row
                ftpMax = .UsedRange.Rows.Count
                Set ftpRange = .Range(.Cells(1, 1), .Cells(ftpMax, ftpMaxCol).End(xlUp))

                With ftpRange
                    .AutoFilter
                    .AutoFilter field:=meterRdCol, Criteria1:=vbNullString ' or "="

                    ' Make a new sheet and copy filtered data to it to be able to address each row
                    .SpecialCells(xlCellTypeVisible).Copy
                    Set filtSheet = Sheets.Add(After:=Sheets(1))
                    filtSheet.name = fltShtName
                    filtSheet.Paste
                    Application.CutCopyMode = False         ' Clear clipboard of copied data
Since the .AutoFilter catches everything as it should, it seems to be a failure of the .SpecialCells function or the labeling of the last row as 'visible'. Any help?
 
Thanks for trying. The VBA is tightly tied to a process and that is why I said "I wish I could". Without the environment, looking at the code is all you can do. I am clueless as to why I am losing the bottom row...
 
Upvote 0

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Why are you using .Cells(ftpMax, ftpMaxCol).End(xlUp) rather than just .Cells(ftpMax, ftpMaxCol)?

It looks like your last column has some empty rows (as in the row that doesn't get copied), so the End(xlUp) part will restrict your range to the rows above that (the autofilter ignores that and filters the whole region whether you like it or not!).
 
Upvote 0

Forum statistics

Threads
1,217,358
Messages
6,136,093
Members
449,991
Latest member
IslandofBDA

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top