title: VBA code required to loop through different sized rows of data and return MAX value
body: <p>I am currently automating a dashboard creation and I've hit a bit of a roadblock. I need some code that will go through about 7000 rows of data and return the highest value in a certain column for each specific item. The data is copied from a pivot table and so is broken down into row sections, I have attached a mock of what it looks like.</p>
  
  <p><a href="https://i.stack.imgur.com/1ouwh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1ouwh.png" alt="enter image description here"></a></p>
  
  <p>I need the highest value in Column G for each portfolio, and will need to use the portfolio code (e.g. XY12345 - They are always 7 characters) to map that value to the dashboard. </p>
  
  <p>My issue is, each portfolio has a different number of rows for the values, and some have blank cells between them, and therefore I am stumped. I was hoping to use Column J to count the number of rows for each portfolio (as there are no breaks for the portfolios in this column) and then use a loop to loop through each portfolios rows of values, based off the Column J count, and then return the highest row value for each portfolio. Problem is I'm new to VBA and have been teaching myself as I go, and I've yet to use a loop.</p>
  
  <p>Many thanks,</p>
  
  <p>Harry</p>