I need to copy paste big sheets, this is taking a lots of time. I have been advised not to use .copy process on worksheets but rather proceeds cell by cell. Giving new cells each properties of the ancient cell. This is what I do here: Saving only some sheets in another Workbook.
To do it cells by cells I need to know the last cell containing information. (not only value, but colour, borders... etc). I've seen many simple solution on internet, but they all have a problem.
ActiveSheet.UsedRange.Rows.Count often gives too many values... I got a 810 * 16000 answer for a 5 * 18 table
range("A" & activesheet.rows.count).end(xlup).row works only for the first columns...
What would be the best way to procedd to final the real last line with value ? containig information (value, colour, border...)
This command in Excel 2010
ActiveCell.SpecialCells(xlLastCell).Select
will move the cursor (active cell) to the last one that had a non-trivial value, even if the cell currently is blankThis command
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
will select all cells from the current to the last one that had a non-trivial value.Both these approaches work for me for getting the last cell 2007. I have used the "UsedRange" method in Excel 2003 as well.
If they do not work for you then your spreadsheet may have something in it that Excel is not showing you. This has happened to me before. The fix would be to select every empty row below your real data and right-Click->Delete them (Same with columns to the right).
Shortcut to delete rows: Shift+Space, Shift+Control+DownArrow, Rightclick->Delete
Shortcut to delete columns: Control+Space, Shift+Control+RightArrow, Rightclick->Delete
examples:
or
Save the Following code to a class file name FinalRowLocator
then:
Provided you have ascertained the correct finalrow, the following should work.
Additional Usage Information: