title: VBA Code to search column for next non empty cell, move up 1 cell & paste something into it.. do until it done
body: <p>I'm new to VBA and need code to find the next non-empty cell in column B (until there are no more rows with data), copy header B5:Last non-empty cell into the row above where it found the non-empty cell(right now it's B5:P5, but it will change each time there is a new month. Each of these headers is used for pivot tables.</p>
  
  <p>Basically, this is a download from accounting software and it isn't formatted correctly with headers, so I have to add them manually. Each of the sections in the worksheet is different sizes and will continue to change in size when the year progresses and additional accounting codes are used.</p>
  
  <p>I do not have any code at this time.</p>
  
  <p>Example of Header Row in Row 5</p>
  
  <pre><code>MainAccount DEPT    Dep Lookup  Dep Lookup  Dep Lookup  PROD
  </code></pre>
  
  <p>Let's just say that the first data point found in column B is found at B28, I need the header row copied and pasted from B5: last in a row to the row just above where it found the first data in B28, meaning that it will be pasted starting in B27.</p>
  
  <pre><code>61000   2110                
  61000   2110                1
  61000   2110                3
  61000   2120                
  61000   2120                1
  61000   2120                3
  61000   2120                4
  </code></pre>
  
  <p>Now it looks again in column B and finds the next data point in B100. I need the header copied and pasted from B5:last in row to B99. It keeps doing this until there is no more data. The placement of the data in rows will change from month to month.</p>
  
  <pre><code>76200               
  76200   1000            
  76200   2020            
  76200   2100            
  76200   2110            
  76200   2115    
  </code></pre>
  
  <p>I expect that for each time the codes finds a value in column B, that it will go up 1 row and paste the header into it. It will do this until there is no more data (basically, the rows will just be blank).</p>