VBA referencing a specific cell on a specific tab and using this to compare data from two Tabs in te workbook

Hagrid1

New Member
Joined
May 5, 2016
Messages
13
Please bear with me as I am definitely not an EXCEL or VBA guru, and I do not know if this has been previously described in the forum.

I have a workbook where I am trying to compare 2 excel files to show that they are the same.

The file is extracted from a database as a CSV to a secure location - (Original data) and then copied to a 2nd location for use - (Moved Data)

To do this I have a front tab (Tab1) where I have a report that provides a whole load of information from the name of the files being compared and their location and hope to report the number of differences

Tab 2 is the location where file 1 is imported to (Original data)

Tab 3 is where file 2 is imported to (Moved Data)

Tab 4 is where I compare each cell using the following formula:

=IF('Original data'!A1="","",IF('Original data'!A1='Moved Data'!A1,"Y","N"))

the above formula is repeated for every cell for approximately 800 columns and 6000 rows comparing. This makes loading the workbook very time consuming but more importantly may not capture al the imported data if the data goes beyond the pre-set range.

Can some one please show me how to:

1) in VBA reference the maximum Column no which I report in say Tab 1 Cell C20 lets say this is Ix and the same for the maximum Row again in Tab1 Cell 21 and call it Jx

2) make a loop coding to place an appropriate formula (for that above) to be placed in each cell in tab 4 so that every cell form A1 to (Jx,Ix) is covered (this way every cell in the original data file tab (tab 2) will be compared to that in Tab 3 and the outcome displayed in tab 4


e.g.

Tab 1 cell C20 = 5 (the maximum no of columns used in tab 2)
cell C21= 4 (the maximum no of rows used in tab 2)

Tab2 : contents

(row/column) a b c d e
1 ABC 1 3 4 A
2 BCD 1 2 4 F
3 CDE 2 3 4 X
4 FGH 4 3 4 B

Tab3 : Contents

(row/column) a b c d e
1 ABC 1 3 4 ?
2 BCD 1 2 4 F
3 CDE 2 3 4 X
4 FGH 4 9 4 B

Tab 4 should fill with the formula from A1 to E4 such that it will compare each cell and report an "N" for cell E1 and C4 as both these are different in tab 3 to tab 2

any help would be appreciated
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
I have just noticed that the tab contents have realigned on posting

so where columns are the letters A to E and the rows are 1 to 4 for the example data:
Tab 2 would be -
() a b c d e
1 ABC 1 3 4 A
2 BCD 1 2 4 F
3 CDE 2 3 4 X
4 FGH 4 3 4 B

whilst Tab 3 would have "?" instead of "A" at E1 and "9" instead of "3" at C4
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,183
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top