VBA Code to Count and Total the Number of Blank Rows

Eshleman

New Member
Joined
Mar 11, 2016
Messages
3
Hi.

I'm looking for VBA code that counts and totals the number of nonblank rows between data in column F of my spreadsheet. The issue that I am having is that the number of rows is not consistent. For example, the data looks like this:



F1 $1,200
F2 blank
F3 $128
F4 blank
F5 $105
F6 $100
F7 $200
F8 blank

The spreadsheet is very large. The above data is just an example. So, in column G, I need to see a 1 in cell G1. I need to see a 1 in G3. And, I need to see a 3 in cell G5. For cells that are blank in column F, the respective cells in column G should also be blank.
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Here's the code and the results of running the code.
Code:
Sub Eshleman()
Dim j
    For Each j In Range("F1", Range("F" & Rows.Count).End(xlUp)).SpecialCells(2).Areas
        j(1, 2).Value = j.Rows.Count
    Next j
End Sub

Excel Workbook
FG
1$1,2001
2
3$1281
4
5$1053
6$100
7$200
Sheet1
 
Upvote 0

Forum statistics

Threads
1,223,240
Messages
6,170,951
Members
452,368
Latest member
jayp2104

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