title: Excel VBA to split cell into multiple cells
body: <p>Good afternoon,</p>
  
  <p>I am having a big issue in my quest to learn VBA. Currently, my data is (as below) in a structure that sometimes contains multiple serial numbers belonging to a single part.</p>
  
  <p>I have a VBA macro that I wrote which imports this data and formats it appropriately for a separate program. However, I am working on a sub that will allow me to go through and separate these serial numbers that are delimited by a comma. </p>
  
  <p>For example:
  <a href="https://i.stack.imgur.com/Gwntu.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Gwntu.jpg" alt="Before Macro"></a></p>
  
  <p>But, I want it to look like this:
  <a href="https://i.stack.imgur.com/zNP6R.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zNP6R.jpg" alt="After Macro"></a></p>
  
  <p>I found some code on this site (<a href="https://stackoverflow.com/questions/42836094/split-cells-into-multiple-rows-using-vb-code">Split Cells Into Multiple Rows using Vb Code</a>) which has helped, but I am having trouble with it: Here is what I have</p>
  
  <pre><code>Sub SplitSerial()
      Dim SN As String
      Dim i As Integer
      Dim numArray()
  
      SN = ActiveCell.Value
      numArray = Split(SN, " ")
      For LBound(numArray) To UBound(numArray)
          Cells(1, i + 1).Value = numArray(i)
          MsgBox numArray(i)
      Next i
  End Sub
  </code></pre>
  
  <p>The problem is, this spreadsheet can get pretty large (5,000+) rows, so I don't know how to have it loop through the column, and if it has a ",', split the serial numbers but copy the values from the remaining cells.</p>
  
  <p>Any guidance, advice, or coaching would be greatly appreciated. I am trying very hard to learn VBA.</p>