title: Duplicating rows of excel data
body: <p>This macro works great for duplicating rows based on an integer value in a specific column.  How do I get it to also copy the formatting of the original data?</p>
  
  <pre><code>Sub DuplicateRows()
  
  Dim currentRow As Integer
  Dim currentNewSheetRow As Integer: currentNewSheetRow = 1
  
  For currentRow = 1 To 3 'The last row of your data
  
      Dim timesToDuplicate As Integer
      timesToDuplicate = CInt(Sheet1.Range("D" &amp; currentRow).Value2)
  
      Dim i As Integer
      For i = 1 To timesToDuplicate
  
          Sheet2.Range("A" &amp; currentNewSheetRow).Value2 = Sheet1.Range("A" &amp; currentRow).Value2
          Sheet2.Range("B" &amp; currentNewSheetRow).Value2 = Sheet1.Range("B" &amp; currentRow).Value2
          Sheet2.Range("C" &amp; currentNewSheetRow).Value2 = Sheet1.Range("C" &amp; currentRow).Value2
  
          currentNewSheetRow = currentNewSheetRow + 1
  
      Next i
  
  Next currentRow
  
  End Sub
  </code></pre>