title: find number of columns used in a excel worksheet using macro
body: <p>I am working on excel sheets using <code>macros</code>.</p>
  
  <p>I wanted to count the number of columns used in the sheet.
  I used:<br><br>
       <code>ColLen = ActiveSheet.UsedRange.Columns(ActiveSheet.UsedRange.Columns.Count).Column</code>
  <br><br>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.
  <br>Another command is giving the correct value for number of columns, which is:<br><br><code>ColLen = Activeworksheet.Cells(1, Columns.count).End(xlToLeft).Column
  </code><br><br></p>
  
  <p>Its other part i.e. number of rows used giving correct value in all sheets.
  <br><br><code>RowLen = ActiveSheet.UsedRange.Rows(ActiveSheet.UsedRange.Rows.count).Row</code><br><br>
  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.</p>