count from cell bottom up

Danny54

Active Member
Joined
Jul 3, 2019
Messages
295
Office Version
  1. 365
Platform
  1. Windows
how would I go about getting a cell count from the bottom up?

what i'm trying to do is start in column g
the last row where the cell contains a date and not colored in
counting upward until i find the cell that's filled with a color
when it does, on that same row insert in cell g the count
start the upward count again from the next cell doing the same until at the top.

example

col ("G")
cell filled with color orange
date
date
date
date
cell filled with color orange
date
date

so the net effect would be

4 <-leave color and insert the count
date
date
date
date
2 <-leave color and insert the count
date
date

would there be a formula or do i need to code a vba routine?



Thanks
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Sorta worked something out that goes this way

Option Explicit

Sub pCount()
Dim lRow As Long, rcount As Long, i As Long

lRow = Cells(Rows.Count, 1).End(xlUp).Row
rcount = 0

For i = lRow To 1 Step -1
rcount = rcount + 1
If Cells(i, 7).Interior.Color = RGB(148, 154, 126) Then
Cells(i, 7) = rcount - 1
rcount = 0
End If
Next i

End Sub
 
Upvote 0

Forum statistics

Threads
1,214,591
Messages
6,120,427
Members
448,961
Latest member
nzskater

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