I have a set of data that is sorted on the column "Year". I started with a small set to build my code, so there are only around 500 rows. There are about 15 different values in the column "Year" and I want to make a graph for each column separately. To do this I need to know at which row one year starts and on which row it ends. Therefore I either need the large set of data divided into separate arrays per year, or an array that contains the start and end rows per year, so that I can reference them in my code that produces the graphs.
I was thinking of writing a loop that checks whether or not the value for a row in column "Year" is different from the value above, using something like this:
For row = 3 to TotalRows
IfNot Cells(row,1).Value = Cells(row-1,1).Value Then
'Row = startrow current year
'Cells(row,1).Value = current year
'Row -1 = endrow previous year
'Cells(row-1,1).Value = previous year
End If
Next row
What would be the best way to store these values, so that I can reference them later?