2010-09-24 71 views
0

我需要找到一种方法来确定2个Excel文档是否基本上基于相同的术语。确定2个Excel文档是否共享相同的结构

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

有没有一个聪明的方法来做到这一点?

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

任何想法?

问候,

+1

你能更具体还是更好的提供一些代码。 VBA不太擅长检查“基本上”相同的材料。文件是否相同,或者您必须明确提供变体。 – ForEachLoop 2010-09-24 14:02:16

+0

命名你是指标题和类似的?比较一张纸的特定部分并不难。 – Fionnuala 2010-09-24 14:23:45

+0

现在基本上我需要检查两个文件中的两个细节是相同的。这些列可以有数百万行... – Farid 2010-09-24 15:01:03

回答

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 

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

Regards,