VBA: Count the Number of Used Columns
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
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
I am automatinmg some spread sheet that are for calculations
Public Sub CountMyColumns()
MsgBox Selection.Columns.Count
End Sub