【问题标题】:Merging 2 datasets in excel with the only common feature 2 date-colums (date deal announced and date deal completed)在 excel 中合并 2 个数据集,具有唯一的共同特征 2 个日期列(宣布交易日期和完成交易日期)
【发布时间】:2016-09-30 10:36:50
【问题描述】:

对于 STATA 中的回归分析,我收到了两个单独的 Excel 文档,每个文档都包含各种剥离交易(和附加功能)。 目标 Excel 表(包含 STATA 等的控制变量)不包括任何剥离交易的标识符(没有交易编号、CUSIP、公司名称或任何标识哪些公司进行剥离的内容)。但它确实包括交易公告日期和交易完成日期。

我得到的第二张表包含比第一张更多的交易和必要的标识符。它还包括 2 列:交易公告日期和交易完成日期。

现在我需要以某种方式将第二个 excel 文件中的标识符分配给第一个文件,仅使用关于交易公告/完成的 2 列(因为这是它们唯一的共同点)。

这里有没有人知道如何在 excel(花哨的 Vlookup )或宏中做到这一点? 我将非常感激,因为我正在谈论超过 5000 笔资产剥离交易,并且认为手动操作不会奏效。

提前谢谢大家

【问题讨论】:

    标签: excel merge vba


    【解决方案1】:
    Function Merger(a(), b()) 'a has all lines, b doesn't, **first column is SORTED**
    Dim i1&, i2&, j&, output
    ReDim sortie(1 To UBound(a), 1 To UBound(a, 2) + UBound(b, 2) - 1)
    i1 = 1: i2 = 1
    Do While i2 < UBound(b) And i1 < UBound(a)
        If a(i1, 1) = b(i2, 1) Then
            For j = 2 To UBound(b, 2)
                a(i1, UBound(a) + j - 1) = b(i2, j)
            Next
            i1 = i1 + 1
            i2 = i2 + 1
        ElseIf a(i1, 1) < b(i2, 1) Then
            i1 = i1 + 1
        Else
            Stop 'either not sorted or not present in a
        End If
    Loop
    Merger = output
    End Function
    

    【讨论】:

      猜你喜欢
      • 2022-10-19
      • 2020-11-17
      • 1970-01-01
      • 2021-11-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-10-11
      相关资源
      最近更新 更多