Summary: I\'m taking a row of data from one sheet and pasting it into another, however the sheet would be a daily use kind of thing where new data is just e
This two line do the magic
usedCol = ThisWorkbook.ActiveSheet.UsedRange.SpecialCells(xlCellTypeLastCell).Column
usedRow = ThisWorkbook.ActiveSheet.UsedRange.SpecialCells(xlCellTypeLastCell).Row
For more info visit Microsoft's site
http://msdn.microsoft.com/en-us/library/office/ff196157.aspx
Change: usedRows = Sheets("EFT").UsedRange.Count
To: usedRows = Sheets("EFT").Range("A" & Sheets("EFT").Rows.Count).End(xlUp).Row
Where "A" can be changed to whichever row you wish to count the total number of columns.
There is a danger in using UsedRange
because it factors in such things and formatted cells with no data and other things that can give you unexpected results, like if you are expecting your data to start in Range("A1"), but it really starts in another range!
I will say, however, that If you really wish to use UsedRange
, your code above is still wrong to get the rows. Use this instead UsedRange.Rows.Count
or to get the last absolute cell of the UsedRange, use UsedRange.SpecialCells(xlCellTypeLastCell).Row
Thanks for the discussion...
.UsedRange.Rows.Count
and .UsedRange.Columns.Count
work fine provided there is something in cell A1. Otherwise need to use the SpecialCells solution.
Hope this is helpful.