确定2个Excel文档是否共享相同的结构

时间:2010-09-24 09:43:34

标签: vba

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

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

为了这么做,有没有聪明的方法?

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

有什么想法吗?

此致

1 个答案:

答案 0 :(得分:0)

以下是我要找的内容:

' 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

如果有任何建议请分享!

此致