2014-04-29 39 views
-1

列表下面是我的要求(在每張紙上有不同的行數)比較兩個工作表,並獲得不匹配的行

1.Two張可,說Sh1時,Sh2的

2。兩行之間的行數不同(行數可能/可能不一樣)

3.Used列的數據因數據不同而不同 但是在任何給定的時間點,相同數量的舊列 (理想情況下,兩張紙的範圍都是動態的)

4.現在我需要對它們進行比較,並找出Sh1,Sh2中的多餘記錄並將它們保存在差異工作表Sh3,Sh4中。

5.比較來執行需要是Sh1的& Sh2的 6.I喜歡使用陣列(裝入到工作表陣列)之間的水平行比較並在其上和返回值進行比較 - 性能起主要作用以來數據可能是關閉數百萬記錄

  1. 有沒有辦法執行比較兩個大小不相同的數組?
  2. 匹配的行可以忽略不計

  3. 是否有應用一些加入()函數,並在array1閱讀完整的一行,並與數組2比較的方法嗎?

對不起如果違反論壇規則的任何手段!

我希望有在兩張紙上用不同的動態比較沒有討論範圍要麼在這裏或其他地方找到的不匹配

我主要是看脂肪酶限制了比較,只有一列,或者僅僅是爲了固定範圍

我的終極目標是做一些VBA代碼,它運行着一些「超比較」(好吧,不是確切的行爲,讀它像一樣)

+0

是將這些文件導入MS Access的一個選項嗎?它非常適合這種情況。 – RubberDuck

回答

0

我一直在研究一種類似的vba宏。 希望下面的代碼有幫助!

所有你需要的是圖片,包括是 如果可能的話 2)通過陣列循環和尋找的區別1)行水平相比

**我

下面的代碼所示:

「比較代碼

子CompareMacro()

Application.ScreenUpdating = True 
Dim sheet1, sheet2, sheet4, sheet3 As Worksheet 
Dim rComp, rcomp1 As Range, addy As String, addz As String 
Dim iRow As Long, jCol As Long 
Dim kRow As Long, lCol As Long 
Dim strFileRange As String 
Dim strDBRange As String 



Set sheet1 = Sheets("File") 
Set sheet2 = Sheets("DB") 
Set sheet3 = Sheets("File(-)DB") 
Set sheet4 = Sheets("DB(-)File") 


sheet1.Select 
Set rComp = sheet1.UsedRange 

sheet2.Select 
Set rcomp1 = sheet2.UsedRange 


addy = rComp.Address 
addz = rcomp1.Address 
ary1 = rComp 
ary2 = rcomp1 
ary3 = sheet3.Range(addy) 
ary4 = sheet4.Range(addz) 

'*********File MINUS DB code goes here********* 

'Step 1 
'VALIDATE IF THE ROW1 OF File matches with Any of the Row in DB 
'This step should include Iteration of Rows in DB range 


'Step 2 
'Proceed with Next row (ROW1+1 OF File) if Match Occurs 
'This step contains incremental of File row & Starting comparison from First Row of DB 

'Step 3 
'If no Match occurs , Add the Specific Row to ary3 
'This step captures the complete Mismatch record of File Row 


'*********DB MINUS File code goes here********* 


'Similar to the Flow of File MINUS DB 



'adding the Array3 & 4 resultant Sheets 

sheet3.Range(addy) = ary3 
sheet4.Range(addz) = ary4 

End Sub

相關問題