I am working on excel sheets using macros
.
I wanted to count the number of columns used in the sheet.
I used:
ColLen = ActiveSheet.UsedRange.Columns(ActiveSheet.UsedRange.Columns.Count).Column
on a particular workbook and it gave a value one greater than the used number of columns.
On other normal excel workbooks, it is giving the correct value.
Another command is giving the correct value for number of columns, which is:ColLen = Activeworksheet.Cells(1, Columns.count).End(xlToLeft).Column
Its other part i.e. number of rows used giving correct value in all sheets.
RowLen = ActiveSheet.UsedRange.Rows(ActiveSheet.UsedRange.Rows.count).Row
Any clue what can be wrong in that sheet? I can't explain its details as told by my company. So, it may be difficult to answer as it may be illogical to ask. If you have any idea, please tell.