English 中文(简体)
基于单元价值(集团公司共同发送1行的电子邮件)的混合电子邮件地址
原标题:Combine Email address based on Cell Value (group companies emails together on 1 line)

在下面的屏幕上,我正试图说明我如何能够把与一家公司相关的所有电子邮件汇合在一起。 我已尝试过TEXTJOIN,但可以说明这项工作的逻辑。 我也愿意接受任何世行解决办法。

“Excel


Compnay Name Billing Account Number Sales Account Number Email Address Output
Blue Bonet 1 1ABC [email protected] [email protected]; [email protected]
Blue Bonet 1 1ABC [email protected]
Disney 2 2ABC [email protected] [email protected]; [email protected]; [email protected]; [email protected]
Disney 2 2ABC [email protected]
Disney 2 2ABC [email protected]
Disney 2 2ABC [email protected]
Berkshire 3 3ABC [email protected] [email protected]
Mia s Pizza 4 4ABC [email protected] [email protected]; [email protected]; [email protected]
Mia s Pizza 4 4ABC [email protected]
Mia s Pizza 4 4ABC [email protected]
Jerry s Barber Sho 5 5ABC [email protected] [email protected]
Tom s Dinner 6 6ABC [email protected] [email protected]; [email protected]; Norwood.O [email protected]
Tom s Dinner 6 6ABC [email protected]
Tom s Dinner 6 6ABC Norwood.O [email protected]
Gilberts 7 7ABC [email protected] [email protected]; [email protected]; [email protected]; [email protected]
Gilberts 7 7ABC [email protected]
Gilberts 7 7ABC [email protected]
Gilberts 7 7ABC [email protected]
问题回答

这里是使用()进行这项工作的一种方式。

“enterography


=MAP(A2:A19,LAMBDA(α,IF(ROW(α)=XMATCH(α,A:A),TEXTJOIN("; ",,FILTER(D:D,A:A=α)),"")))

然而,如果你想要缩小公式,上述公式就会消失:

=TEXTJOIN("; ",,FILTER($D$2:$D$19,(A2=$A$2:$A$19)*(COUNTIF(A$2:A2,A2)=1),""))

  • Load data into an array, group Email with a Dict object
Option Explicit
Sub Demo()
    Dim objDic As Object, rngData As Range
    Dim i As Long, sKey As String, colCell As Collection
    Dim arrData, arrRes, RowCnt As Long
    Const KEY_COL = 2     group by `Billing Account Number`
    Const DATA_COL = 4    concate Email
    Const DEST_COL = 5    output to Col E
    Set colCell = New Collection
    Set objDic = CreateObject("scripting.dictionary")
      load data into array
    Set rngData = Range("A1").CurrentRegion
    arrData = rngData.Value
    RowCnt = UBound(arrData)
      loop through data
    For i = LBound(arrData) + 1 To RowCnt
        sKey = arrData(i, KEY_COL)
        If objDic.exists(sKey) Then
            objDic(sKey) = objDic(sKey) & "; " & arrData(i, DATA_COL)
        Else
            objDic(sKey) = arrData(i, DATA_COL)
            colCell.Add i
        End If
    Next i
      populate output array
    ReDim arrRes(1 To RowCnt, 0)
    arrRes(1, 0) = "Output"
    For i = 1 To objDic.Count
        arrRes(colCell(i), 0) = objDic.items()(i - 1)
    Next
      write output to sheet
    Cells(1, DEST_COL).Resize(RowCnt, 1).Value = arrRes
End Sub




相关问题
import of excel in SQL imports NULL lines

I have a stored procedure that imports differently formatted workbooks into a database table, does work on them then drops the table. Here is the populating query. SELECT IDENTITY(INT,1,1) AS ID ...

Connecting to Oracle 10g with ODBC from Excel VBA

The following code works. the connection opens fine but recordset.recordCount always returns -1 when there is data in the table. ANd If I try to call any methods/properties on recordset it crashes ...

Excel date to Unix timestamp

Does anyone know how to convert an Excel date to a correct Unix timestamp?

C# GemBox Excel Import Error

I am trying to import an excel file into a data table using GemBox and I keep getting this error: Invalid data value when extracting to DataTable at SourceRowIndex: 1, and SourceColumnIndex: 1. As ...

Importing from excel "applications" using SSIS

I am looking for any tips or resources on importing from excel into a SQL database, but specifically when the information is NOT in column and row format. I am currently doing some pre-development ...

热门标签