有没有办法生成一个唯一值列表,从 excel 或 google 工作表中的多个数组中提取?
Is there a way to generate a list of unique values, extracted from more than one array in excel or google sheets?
我可以从不同工作表中的不同列生成唯一值列表吗?
它可以在 excel 或 google 张中。
类似于:
=排序(唯一(列 1、列 2、列 3、假、假))
谢谢!
gs 支持:
=SORT(UNIQUE({Sheet1!A1:A100; B10:B30; Sheet5!C8:C}))
假设我们有:
并且我们需要两列中项目的排序列表。
首先将以下 UDF()
放入标准模块中:
Public Function stack(ParamArray arr()) As Variant
Dim r As Range, arr_cnt As Long, i As Long, cell_cnt As Long
Dim Liist, Li As Long, rr As Range, ic As Long, ir As Long
Dim iir As Long, iic As Long
arr_cnt = UBound(arr)
cell_cnt = 0
For i = 0 To arr_cnt
Set r = arr(i)
cell_cnt = cell_cnt + r.Count
Next i
ReDim Liist(1 To cell_cnt, 1 To 1)
Li = 1
For i = 0 To arr_cnt
Set r = arr(i)
ic = r.Columns.Count
ir = r.Rows.Count
If ic > 1 And ir > 1 Then
For iic = 1 To ic
For iir = 1 To ir
Liist(Li, 1) = r(iir, iic)
Li = Li + 1
Next iir
Next iic
Else
For Each rr In r
Liist(Li, 1) = rr.Value
Li = Li + 1
Next rr
End If
Next i
stack = Liist
End Function
UDF 采用一组范围并生成一个与列兼容的值数组。选择一个单元格并输入:
=SORT(UNIQUE(stack(A1:A6,C1:C5)))
我可以从不同工作表中的不同列生成唯一值列表吗? 它可以在 excel 或 google 张中。
类似于:
=排序(唯一(列 1、列 2、列 3、假、假))
谢谢!
gs 支持:
=SORT(UNIQUE({Sheet1!A1:A100; B10:B30; Sheet5!C8:C}))
假设我们有:
并且我们需要两列中项目的排序列表。
首先将以下 UDF()
放入标准模块中:
Public Function stack(ParamArray arr()) As Variant
Dim r As Range, arr_cnt As Long, i As Long, cell_cnt As Long
Dim Liist, Li As Long, rr As Range, ic As Long, ir As Long
Dim iir As Long, iic As Long
arr_cnt = UBound(arr)
cell_cnt = 0
For i = 0 To arr_cnt
Set r = arr(i)
cell_cnt = cell_cnt + r.Count
Next i
ReDim Liist(1 To cell_cnt, 1 To 1)
Li = 1
For i = 0 To arr_cnt
Set r = arr(i)
ic = r.Columns.Count
ir = r.Rows.Count
If ic > 1 And ir > 1 Then
For iic = 1 To ic
For iir = 1 To ir
Liist(Li, 1) = r(iir, iic)
Li = Li + 1
Next iir
Next iic
Else
For Each rr In r
Liist(Li, 1) = rr.Value
Li = Li + 1
Next rr
End If
Next i
stack = Liist
End Function
UDF 采用一组范围并生成一个与列兼容的值数组。选择一个单元格并输入:
=SORT(UNIQUE(stack(A1:A6,C1:C5)))