Was hoping to get some advice on my partially working code, I had received good advice on VBA code to copy rows based on cell value (H) and paste into a new sheet named after the cell value.
However, the code I am using gives a run-time error and after Excel stops responding/restarts it seems like the code only ran through half the data. Any and all advice is appreciated.
Sub CopyCodeshort()
Application.ScreenUpdating = False
Dim rCell As Range
Dim lastrow As Long
Dim shtData As Worksheet, shtDest As Worksheet
Dim sheetName As String
Set shtData = Worksheets("Data")
lastrow = shtData.Cells(Rows.Count, 1).End(xlUp).Row
For Each rCell In shtData.Range("H2:H" & lastrow).SpecialCells(xlCellTypeConstants)
sheetName = rCell.Value
If Not SheetExists(sheetName) Then
Set shtDest = Worksheets.Add(, Worksheets(Worksheets.Count))
shtDest.Name = sheetName
shtData.Rows(1).EntireRow.Copy shtDest.Rows(1)
Else
Set shtDest = Worksheets(sheetName)
End If
shtDest.Range("H" & Rows.Count).End(xlUp).Offset(1, 0).EntireRow.Value = _
rCell.EntireRow.Value
Next rCell
Application.ScreenUpdating = True
End Sub
EDIT: After taking your awesome advice, I made some slight tweaks and now Excel doesn't crash anymore, but I still get an error stating I don't have enough memory and then I get run-time error 1004. Partial results are getting more comprehensive, but still missing data.