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

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
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,213,487
Messages
6,113,938
Members
448,534
Latest member
benefuexx

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