Hi,
I'm using the dates as markers: Every date marks a new batch of data for that date; the data is below the date until the point a new date is found. In this example the marked cells are dates (rows 1, 21, 31) with data from each date listed below the date. Everything below 8/24 is from 8/24; everything from 9/2 is from 9/2 etc. Step one is defining these date-markers.
Screenshot 2021-06-01 105654.jpg
Ok, so here's my macro :
Sub LoopTest1()
Dim TNV As Integer
Dim R As Integer
Dim NR As Integer
'
NR = Cells(Rows.Count, 1).End(xlUp).Row
TNV = 0
'
For R = 1 To NR
TNV = TNV + IsDate(Range("a" & R))
Cells(1, 4) = R
Cells(1, 5) = TNV
Next R
'
End Sub
NR = find the last row of data
R = for/next loop counter, which doubles as a row counter
TNV = 'the new value' that is added to each time a date is found. Since IsDate is a TRUE/FALSE or 1/0 result, I simply added each IsDate result to the TNV running total.
So I have it looking through column A while displaying the R and TNV values as the loop is running. The thing is TNV goes negative. TNV displays the correct number of dates (1, 3, 15 whatever), but in negative (-1, -3, -15 whatever).
I'm stumped.
Thank you.
Bookmarks