VBA: Count the Number of Used Columns

September 7th, 2004 | Categories: VBA | Tags:
-->

The following code will return in a message box the total number of columns used in a worksheet. Empty columns are considered used if data follows the empty column.

MsgBox ActiveSheet.UsedRange.Columns.Count
Can't get the tutorial to work for you? Need help with your code?
Get answers right away at our AE Excel Support Forums!
  1. Hank Gerdes
    December 13th, 2010 at 21:19
    Reply | Quote | #1

    I am automatinmg some spread sheet that are for calculations

  2. deepan
    March 25th, 2011 at 10:08
    Reply | Quote | #2

    Public Sub CountMyColumns()
    MsgBox Selection.Columns.Count
    End Sub