.
Sub CopiarSoVisivel()
uf1.lb1.Caption = "Estamos separando, por favor aguarde!"
DoEvents
Dim oSheet as Object[n]oSheet = ThisComponent.CurrentController.ThisComponent.CurrentController.ActiveSheet[n]ThisComponent.CurrentController.select(oSheet.getCellDim oSheet as Object[n]oSheet = ThisComponent.CurrentController.ActiveSheet[n]oSheet.getCellRangeByName($1)ByName(("A1")))
Set sw = ThisComponent.CurrentController.ActiveSheet
t = 2
x = 2
agenteatual = sw.Cells(x, 8)
'Do While sw.Cells(x, 1) <> Empty
door2:
sw.Dim oSheet as Object[n]oSheet = ThisComponent.CurrentController.ActiveSheet[n]oSheet.getCellRangeByName($1)("A:N").AutoFilter Field:=8, Criteria1:=agenteatual
Dim oSheet as Object[n]oSheet = ThisComponent.CurrentController.ThisComponent.CurrentController.ActiveSheet[n]ThisComponent.CurrentController.select(oSheet.getCellDim oSheet as Object[n]oSheet = ThisComponent.CurrentController.ActiveSheet[n]oSheet.getCellRangeByName($1)ByName())ion, Dim oSheet as Object[n]oSheet = ThisComponent.CurrentController.ThisComponent.CurrentController.ActiveSheet[n]ThisComponent.CurrentController.select(MoveCursorToEnd(ThisComponent.getCurrentSelection,"(xlDown))"))
Dim oSheet as Object[n]oSheet = ThisComponent.CurrentController.ThisComponent.CurrentController.ActiveSheet[n]ThisComponent.CurrentController.select(oSheet.getCellDim oSheet as Object[n]oSheet = ThisComponent.CurrentController.ActiveSheet[n]oSheet.getCellRangeByName($1)ByName())ion, Dim oSheet as Object[n]oSheet = ThisComponent.CurrentController.ThisComponent.CurrentController.ActiveSheet[n]ThisComponent.CurrentController.select(MoveCursorToEnd(ThisComponent.getCurrentSelection,"(xlToRight))"))
Selection.SpecialCells(xlCellTypeVisible).Select
Selection.Copy
Sheets.Add After:=Sheets(Sheets.Count)
ThisComponent.CurrentController.ActiveSheet.Paste
pathar = ThisWorkbook.Path & "\" & agenteatual
On Error Resume Next
MkDir pathar
Set sw2 = ThisComponent.CurrentController.ActiveSheet
w = 2
ocoatual = sw2.Cells(w, 9)
door1:
' Do While sw2.Cells(w, 1) <> Empty
sw2.Dim oSheet as Object[n]oSheet = ThisComponent.CurrentController.ActiveSheet[n]oSheet.getCellRangeByName($1)("A:N").AutoFilter Field:=9, Criteria1:=ocoatual
Dim oSheet as Object[n]oSheet = ThisComponent.CurrentController.ThisComponent.CurrentController.ActiveSheet[n]ThisComponent.CurrentController.select(oSheet.getCellDim oSheet as Object[n]oSheet = ThisComponent.CurrentController.ActiveSheet[n]oSheet.getCellRangeByName($1)ByName())ion, Dim oSheet as Object[n]oSheet = ThisComponent.CurrentController.ThisComponent.CurrentController.ActiveSheet[n]ThisComponent.CurrentController.select(MoveCursorToEnd(ThisComponent.getCurrentSelection,"(xlDown))"))
Dim oSheet as Object[n]oSheet = ThisComponent.CurrentController.ThisComponent.CurrentController.ActiveSheet[n]ThisComponent.CurrentController.select(oSheet.getCellDim oSheet as Object[n]oSheet = ThisComponent.CurrentController.ActiveSheet[n]oSheet.getCellRangeByName($1)ByName())ion, Dim oSheet as Object[n]oSheet = ThisComponent.CurrentController.ThisComponent.CurrentController.ActiveSheet[n]ThisComponent.CurrentController.select(MoveCursorToEnd(ThisComponent.getCurrentSelection,"(xlToRight))"))
Selection.SpecialCells(xlCellTypeVisible).Select
Selection.Copy
Sheets.Add After:=Sheets(Sheets.Count)
ThisComponent.CurrentController.ActiveSheet.Paste
xFilename = ThisWorkbook.Path & "\" & agenteatual & "\" & "OCO-" & Format(ocoatual, "00")
ThisComponent.CurrentController.ActiveSheet.SaveAs Filename:=xFilename, FileFormat:=xlCSV, CreateBackup:=False
Application.DisplayAlerts = False
ThisComponent.CurrentController.ActiveSheet.Delete
Application.DisplayAlerts = True
sw2.Active
Do While sw2.Cells(t, 1) <> Empty
If sw2.Cells(t, 8) = agenteatual And sw2.Cells(t, 9) <> ocoatual Then
ocoatual = sw2.Cells(t, 9)
GoTo door1
End If
t = t + 1
Loop
Application.DisplayAlerts = False
ThisComponent.CurrentController.ActiveSheet.Delete
Application.DisplayAlerts = True
t = 2
Do While sw.Cells(x, 1) <> Empty
If sw.Cells(x, 8) <> agenteatual Then
agenteatual = sw.Cells(x, 8)
GoTo door2
End If
x = x + 1
If sw.Cells(x, 8) = Empty Then GoTo door3
Loop
door3:
'MsgBox "Não encontramos mais nenhum agenete!"
Exit Sub
'Loop
End Sub
Já usei a extensão Copy only visible cells, não funcionou.
eu usava essa macro no Excel porem estou usando o Calc e ela não funciona no mesmo.