Your code has lots of activate and select. These will slow down the code, specially if the data involves are large.
Try this code. It does the same. I assumed that you want to copy from A4 H4 and headings are in A1-H1
Sub craetenames1()
Dim i As Long, LR As Long, NR As Long, nome As String, sh As Worksheet, ws As Worksheet
Application.ScreenUpdating = False
Application.DisplayAlerts = 0
On Error Resume Next
For Each ws In ThisWorkbook.Worksheets
If ws.Name <> "Total" Then
ws.Cells.ClearContents
End If
Next
With Sheets("Total")
LR = .Cells.Find("*", , , , xlByRows, xlPrevious).Row
For i = 4 To LR
If Trim(UCase(.Range("A" & i).Value)) <> vbNullString Then
nome = Trim(UCase((.Range("A" & i).Value)))
If Not Evaluate("ISREF('" & nome & "'!A1)") Then
Worksheets.Add(after:=Worksheets(Worksheets.Count)).Name = nome
End If
.Range("A1:H1").Copy Worksheets(nome).Range("A1")
.Rows(i).Copy
Worksheets(nome).Range("A" & Rows.Count).End(xlUp)(2).PasteSpecial xlValues
Worksheets(nome).Columns.AutoFit
End If
Next i
End With
Application.CutCopyMode = 0
For Each ws In ThisWorkbook.Worksheets
With ws
Application.DisplayAlerts = 0
If .Name Like "Sheet*" Then ws.Delete
End With
Next
Application.DisplayAlerts = 1
Application.ScreenUpdating = True
End Sub
Bookmarks