Hi, I have a little issue with columns.
A-------B----------C-------D
one---- two------three----four
one---- two------three ----four---------Count A =
one---- two------three ----four---------Count B =
one---- two------three ----four---------Count C =
one--------------three----four----------Count D =
one--------------three
------------------three
------------------three
I want to count how many cells are filled in each column, but I need this to be done autonomously via a macro i.e. when I run the macro, it should give me the total number of filled cells in Col A, Col B, Col C etc... (the number of columns is undefined, depends on how much data coming in). I have the code to count one column, but don't know how to jump to the next one:
Sub CountFrames()
Dim StaticColumn
Dim Row
StaticColumn = 15
Row = 13
Do Until WorksheetFunction.CountA(StaticColumn) = 0
If WorksheetFunction.CountA(StaticColumn) > 0 Then
Cells(Row, 10).Select
Cells(Selection.Row, Columns.Count).End(xlToLeft).Offset(, 1).Select
'offset(C15,0,1)
ActiveCell.FormulaR1C1 = "=COUNTA(C15)"
Row = Row + 1
StaticColumn = StaticColumn + 1
Else
MsgBox "Empty"
End If
Loop
End Sub
Can anyone help?
Many thanks!!
A-------B----------C-------D
one---- two------three----four
one---- two------three ----four---------Count A =
one---- two------three ----four---------Count B =
one---- two------three ----four---------Count C =
one--------------three----four----------Count D =
one--------------three
------------------three
------------------three
I want to count how many cells are filled in each column, but I need this to be done autonomously via a macro i.e. when I run the macro, it should give me the total number of filled cells in Col A, Col B, Col C etc... (the number of columns is undefined, depends on how much data coming in). I have the code to count one column, but don't know how to jump to the next one:
Sub CountFrames()
Dim StaticColumn
Dim Row
StaticColumn = 15
Row = 13
Do Until WorksheetFunction.CountA(StaticColumn) = 0
If WorksheetFunction.CountA(StaticColumn) > 0 Then
Cells(Row, 10).Select
Cells(Selection.Row, Columns.Count).End(xlToLeft).Offset(, 1).Select
'offset(C15,0,1)
ActiveCell.FormulaR1C1 = "=COUNTA(C15)"
Row = Row + 1
StaticColumn = StaticColumn + 1
Else
MsgBox "Empty"
End If
Loop
End Sub
Can anyone help?
Many thanks!!