I have a problem with the code behavior, this code is responsible for filter lines and paste in new worksheet that itself create
This code creates a new worksheet and saves it but doesn't paste the information the copied
Public Contratante As String
Sub Macro1()
Dim rng As Range
Dim WorkRng As Range
Dim total As Long
Dim wb As Workbook
total = 1
On Error Resume Next
xTitleId = "Contar Preenchidas"
Set WorkRng = Application.Selection
Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
For Each rng In WorkRng
If Not IsEmpty(rng.Value) Then
total = total + 1
Contratante = ActiveSheet.Range("K" & total).Value
Workbooks.Add
ActiveWorkbook.SaveAs Filename:="C:\Users\WMRamthun\OneDrive - META CENTRAL DE SERVICOS LTDA\Relatorios Bio\OA\Relatorio NOVO\" & Contratante & ".xlsx"
Workbooks("OA Separa tudo.xlsm").Worksheets("Base").Range("B2").AutoFilter _
Field:=1, _
Criteria1:=Contratante, _
VisibleDropDown:=False
Workbooks("OA Separa tudo.xlsm").Worksheets("Base").Range("B2:H2", Range("B2").End(xlDown).End(xlToRight)).Copy
Workbooks(Contratante & ".xlsx").Worksheets("Planilha1").Range("A2").PasteSpecial Paste:=xlPasteValues
Set wb = Workbooks(Contratante & ".xlsx")
wb.Close SaveChanges:=False
End If
Next rng
MsgBox "Há " & total & " células preenchidas neste intervalo"
End Sub
I try using a sub model using call but didn't solve