Ola @clear, tenho esta macro, faça adaptação para sua área ( fixando os valores x e y ) e a ligue a Eventos de planilha / Ao ativar o documento.
Hi @clear, I have this macro, adapt it to your area (fixing the x and y values) and link it to Sheet Events / On Document Activation.
Sub ToExtractUniqueInPutBox
'fonte: http://www.clubedohardware.com.br/profile/697345-tiank/
Dim mCamposFiltro(0) As New com.sun.star.sheet.TableFilterField
Dim x as String
Dim y as String
Dim xi() as Variant
Dim yi() as Variant
x = inputbox("Extraction area: (Ex: Planilha1.D2:C24)")
y = inputbox("Initial cell for discharge: (Ex: Planilha2.C7)")
msgbox "Extraction area: "& X &" , Initial cell for discharge: "& y
xi = Split( x,"." )
yi = Split( y,"." )
oPlan = ThisComponent.Sheets.getByName( xi(0) )
oIntervalo = oPlan.getCellRangeByName( xi(1) )
'=> esta parte permanece idêntica <=
'Descritor do filtro
oDescFiltro = oIntervalo.createFilterDescriptor( True )
'Definir os campos
mCamposFiltro(0).Field = 0
mCamposFiltro(0).Operator = 1
'Estabelecer o destino
oPlan = ThisComponent.Sheets.getByName( yi(0) )
oDestino = oPlan.getCellRangeByName( yi(1) ).getCellAddress()
'=> Restante permanece igual <=
'Propriedades do filtro padrão
oDescFiltro.ContainsHeader = False
oDescFiltro.SkipDuplicates = True
oDescFiltro.CopyOutputData = True
oDescFiltro.OutputPosition = oDestino
oDescFiltro.FilterFields = mCamposFiltro
oIntervalo.Filter( oDescFiltro )
End Sub