Mega Code Archive

 
Categories / VisualBasic Script / Excel
 

Counts columns in a multiple selection

Sub CountColumnsMultipleSelections()             AreaCount = Selection.Areas.Count     If AreaCount <= 1 Then         MsgBox "The selection contains " & Selection.Columns.Count & " columns."     Else         For i = 1 To AreaCount             MsgBox "Area " & i & " of the selection contains " & Selection.Areas(i).Columns.Count & " columns."         Next i     End If End Sub