我想将仅出现在列表中一次的值分开。
我正在尝试提取没有重复值的值。我知道如何使用公式使用高级过滤器来提取唯一值。但这对我来说是新的挑战。使用帮助专栏我可以做到,但在没有帮助专栏的情况下尝试做
ID
00152
00542
00542
00121
00548
00546
00523
00230
00214
00245
00455
00987
00011
00548
0011
00230
00245
00689
00555
00152
00999
00100
答案 0 :(得分:1)
如果数据在A2:A23中,请尝试在D2:D23(或任何其他列)中使用此数组公式:
'Start a new document in Word
Set oApp = CreateObject("Word.Application")
Set oDoc = oApp.Documents.Add
Set oRange = oDoc.Range
oDoc.MailMerge.MainDocumentType = wdCatalog
oDoc.PageSetup.Orientation = wdOrientLandscape
oDoc.MailMerge.OpenDataSource Name:=FullFilePath, LinkToSource:=True, _
SQLStatement:="SELECT * FROM `namedRangeDynamic`"
With oDoc.MailMerge
Set HdrRange = oDoc.Sections.Item(1).Headers(wdHeaderFooterPrimary).Range
oDoc.Tables.Add Range:=HdrRange, NumRows:=1, NumColumns:=4
Set oTable = HdrRange.Tables(1)
With oTable
.Borders.Enable = True
.Columns(1).SetWidth ColumnWidth:=oApp.CentimetersToPoints(8), RulerStyle:=wdAdjustFirstColumn
.Columns(2).SetWidth ColumnWidth:=oApp.CentimetersToPoints(4.5), RulerStyle:=wdAdjustFirstColumn
.Columns(3).SetWidth ColumnWidth:=oApp.CentimetersToPoints(3.5), RulerStyle:=wdAdjustFirstColumn
.Columns(4).SetWidth ColumnWidth:=oApp.CentimetersToPoints(6.75), RulerStyle:=wdAdjustFirstColumn
.Rows(1).Shading.BackgroundPatternColor = -570408705
.Cell(1, 1).Range.Text = "Account Name"
.Cell(1, 2).Range.Text = "Last Name"
.Cell(1, 3).Range.Text = "First Name"
.Cell(1, 4).Range.Text = "Organization"
End With
oDoc.Tables.Add oRange, 1, 4
Set oTable = oRange.Tables(1)
With oTable
.Borders.Enable = True
.Columns(1).SetWidth ColumnWidth:=oApp.CentimetersToPoints(8), RulerStyle:=wdAdjustFirstColumn
.Columns(2).SetWidth ColumnWidth:=oApp.CentimetersToPoints(4.5), RulerStyle:=wdAdjustFirstColumn
.Columns(3).SetWidth ColumnWidth:=oApp.CentimetersToPoints(3.5), RulerStyle:=wdAdjustFirstColumn
.Columns(4).SetWidth ColumnWidth:=oApp.CentimetersToPoints(6.75), RulerStyle:=wdAdjustFirstColumn
End With
With oTable
.Cell(1, 1).Range.Font.Size = 8
.Cell(1, 1).Range.Font.Name = "Arial"
.Cell(1, 1).Shading.BackgroundPatternColor = -570359809
.Cell(1, 2).Range.Font.Size = 8
.Cell(1, 2).Range.Font.Name = "Arial"
.Cell(1, 3).Range.Font.Size = 8
.Cell(1, 3).Range.Font.Name = "Arial"
.Cell(1, 4).Range.Font.Size = 8
.Cell(1, 4).Range.Font.Name = "Arial"
End With
With .Fields
.Add oApp.Selection.Range, "Account_Name"
oApp.Selection.MoveRight
.Add oApp.Selection.Range, "Last_Name"
oApp.Selection.MoveRight
.Add oApp.Selection.Range, "First_Name"
oApp.Selection.MoveRight
.Add oApp.Selection.Range, "Company"
End With
End With
oDoc.MailMerge.Destination = wdSendToNewDocument
oDoc.MailMerge.Execute
If cb2_selected = "PDF" Then
oApp.ActiveDocument.ExportAsFixedFormat OutputFileName:= _
SaveAs_FilepathA & "\" & lb2_array_acctName & ".pdf", ExportFormat:=wdExportFormatPDF, _
OpenAfterExport:=False, OptimizeFor:=wdExportOptimizeForPrint, Range:= _
wdExportAllDocument, FROM:=1, To:=1, Item:=wdExportDocumentContent, _
IncludeDocProps:=True, KeepIRM:=True, CreateBookmarks:= _
wdExportCreateNoBookmarks, DocStructureTags:=True, BitmapMissingFonts:= _
True, UseISO19005_1:=False
Else
oApp.ActiveDocument.SaveAs2 Filename:=SaveAs_FilepathA & "\" & lb2_array_acctName & ".docx", FileFormat:= _
wdFormatXMLDocument, LockComments:=False, Password:="", AddToRecentFiles _
:=True, WritePassword:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts _
:=False, SaveNativePictureFormat:=False, SaveFormsData:=False, _
SaveAsAOCELetter:=False, CompatibilityMode:=15
End If
'Close Word
oDoc.Close False
oApp.Visible = False
oApp.ActiveDocument.Close SaveChanges:=False
Set oDoc = Nothing
'Prevent save to Normal template
oApp.NormalTemplate.Saved = True
oApp.Quit
Set oApp = Nothing
答案 1 :(得分:1)
终于可以解决问题了。下面是从列表中提取纯唯一值的公式。
=INDEX($B$5:$B$26,AGGREGATE(15,6,(ROW($B$5:$B$26)-ROW($B$4))/(COUNTIF($B$5:$B$26,$B$5:$B$26)=1),ROW(1:1)))