Counting the # of values repeatedly in a column

levanoj

Active Member
Joined
Oct 25, 2007
Messages
311
Is there a code that can provide the sum of the # of values in a particular column? So for example, I have a spreadsheet that looks like this:
MODLBUTN(Test2).xlsx
ABCD
1LACGroupCount
21002Mort2
31002Muni3
41002Deriv1
51002EM1
6
71003Mort1
81003Muni1
91003EM1
10
111005Mort1
121005Deriv1
13
141010Muni55
15
161011Muni57
17
Sheet3


And I'd like a code that will prompt me to select a column (A,B or C) and provide the some in the blank cells of that column of the # of values directly above it and provide a result like this:
MODLBUTN(Test2).xlsx
ABCD
1LACGroupCount
21002Mort2
31002Muni3
41002Deriv1
51002EM1
64
71003Mort1
81003Muni1
91003EM1
103
111005Mort1
121005Deriv1
132
141010Muni55
151
161011Muni57
171
Sheet3


Except for the 1st sum result (row 6) it wouldn't count the header (Group) as a value.
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Hi,

Maybe something like

Code:
Sub Count()
    Dim lastRow As Long, rng As Range
    
    With Sheets("Sheet3")
        lastRow = .Cells(.Rows.Count, "B").End(xlUp).Row + 1
        Set rng = .Range("B1:B" & lastRow).SpecialCells(xlCellTypeBlanks)
        rng.Formula = "=Countif(" & .Range("A2:A" & lastRow).Address _
        & "," & rng.Cells(1, 1).Offset(-1, -1).Address(False, False) & ")"
    End With
End Sub

HTH

M.
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,280
Members
452,902
Latest member
Knuddeluff

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top