Last used column index with data or style on a worksheet

Hi,

What property should I use to retrieve the last used column index on a worksheet? I know there is a Worksheet.Cells.MaxColumn property. However, unlike Worksheet.Cells.MaxRow, it doesn’t clearly state that it’ll return the last column index with data or style.

Thanks.

@vonH,

Please note:

  1. You may use Worksheet.Cells.MaxColumn to get the last column index which contains data or style/formatting.
  2. You may use Worksheet.Cells.MaxDataColumn attribute to get the farthest column index which contains data (only).

Hope, this helps a bit.

1 Like