【问题标题】:Identify whether 2 excel documents share the same structure判断2个excel文档是否结构相同
【发布时间】:2010-09-24 09:43:34
【问题描述】:

我需要找到一种方法来确定 2 个 Excel 文档是否基本上基于相同的命名法。

第一个文档需要从第二个文档加载数据。我想确保第一个文档正确地尝试加载相关数据。

有没有聪明的方法可以做到这一点?

我目前最原始的想法是在 excel 文档中查找需要相同的特定字符串。 或者在excel属性文档中设置一个特殊的字符串属性,检查是否正确。

有什么想法吗?

问候,

【问题讨论】:

  • 您能否更具体一些,或者更好的是,提供一些代码。 VBA 不太擅长检查“基本上”相同的材料。文档是否相同,或者您必须明确提供变体。
  • 您所说的命名是指标题之类的吗?比较工作表的特定部分并不难。
  • 目前我基本上需要检查两个文档中的 2 个具体列是否相同。这些列可以有数百万行...
  • 如果相同,您的意思是相同,请考虑 ADO 和两列上的 INNER JOIN。

标签: vba


【解决方案1】:

这就是我要找的东西:

' Loop through each cell in first Range and compare it with
' each cell in second one.
Function isIdentic(Range As Range, RangeB As Range)

isIdentic = True
Dim counter As Long
counter = 1

For Each Value In Range
toCompare = RangeB.Cells(counter)

    If Value <> toCompare Then
'print the values which are different
    MsgBox Value & " : " & toCompare
    isIdentic = False
    Exit For
    End If

counter = counter + 1
Next Value

End Function

如果有任何建议,请分享!

问候,

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-04-04
    • 2012-09-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-07
    • 1970-01-01
    • 2018-05-14
    相关资源
    最近更新 更多