Ron Bayes
asked on
Excel Macro to Compare between Two Worksheets
Hello,
Please see attached for file structure. I'm looking for a macro that will do the following starting on File_A worksheet row 2:
- IF File_A column C matches File_B column U then Compare File_A column H against File_B column Q. If there is no match, enter YES in column O for that row.
- IF File_A column C matches File_B column U AND File_A column H matches File_B column Q then Compare File_A column G against File_B column O. If there is no match, enter YES in column N for that row.
- IF File_A column C matches File_B column U AND File_A column H matches File_B column Q AND File_A column G matches File_B column O then Compare File_A column K against File_B column R. If there is no match, enter YES in column P for that row.
Please provide macro solution only as this is part of a more complex process. Likely clear as mud but let me know if you have questions. I'm using Excel Office 365 64-bit.
Thanks!
EE-Sample.xlsx
Please see attached for file structure. I'm looking for a macro that will do the following starting on File_A worksheet row 2:
- IF File_A column C matches File_B column U then Compare File_A column H against File_B column Q. If there is no match, enter YES in column O for that row.
- IF File_A column C matches File_B column U AND File_A column H matches File_B column Q then Compare File_A column G against File_B column O. If there is no match, enter YES in column N for that row.
- IF File_A column C matches File_B column U AND File_A column H matches File_B column Q AND File_A column G matches File_B column O then Compare File_A column K against File_B column R. If there is no match, enter YES in column P for that row.
Please provide macro solution only as this is part of a more complex process. Likely clear as mud but let me know if you have questions. I'm using Excel Office 365 64-bit.
Thanks!
EE-Sample.xlsx
ASKER
I cannot seem to get this to run. Errors out at the call statement. Can you add the code to the sample workbook I originally provided and attach so I can review?
Okay, please find the attached with the codes on Module1.
Please run the code "MainMacro".
I have also tweaked the code as per the matching conditions and added comments in there.
I have inserted a button called "Compare Sheets" on File_A Sheet so that you can run the code by clicking that button also.
EE-Sample_CompareSheets.xlsm
Please run the code "MainMacro".
I have also tweaked the code as per the matching conditions and added comments in there.
I have inserted a button called "Compare Sheets" on File_A Sheet so that you can run the code by clicking that button also.
EE-Sample_CompareSheets.xlsm
ASKER
Thank you. The only thing that does not appear to be working is the Hours Mismatch column. For example, row 1 shows 8.0 hours in column K but the match on File_B shows 7.50. So there should be a Yes in that cell as the hours do not match.
ASKER
Adding to that....I believe all three rows in File_A would show a mismatch based on comparison between the two sheets. So for rows 3 and 4 both the Reason Mismatch and the Hours Mismatch should show YES.
I think you should go through the conditions you posted in the description and I only followed those conditions.
It seems that if FileA col. C is found in FileB col. U, you are trying to track all the mismatches. Is that correct?
Anyways, please find the two files and see which one works for you.
EE-Sample_CompareSheets-_A.xlsm
EE-Sample_CompareSheets-_B.xlsm
It seems that if FileA col. C is found in FileB col. U, you are trying to track all the mismatches. Is that correct?
Anyways, please find the two files and see which one works for you.
EE-Sample_CompareSheets-_A.xlsm
EE-Sample_CompareSheets-_B.xlsm
ASKER
Perhaps I'm making this too complex. At this point all I want is to compare the ID and date fields. If the date field is wrong I want an indicator. If I strip your code down so its only looking at date comparison its showing incorrect result. Based on attached when macro runs, cells O3 and O5 should be blank as the unique ID (column C) matches and the Start Date (column H) matches the other file.
If we can get just this one part to work then I'll be set. Appreciate your assistance and patience.
EE-Sample_CompareSheets-_B_V2.xlsm
If we can get just this one part to work then I'll be set. Appreciate your assistance and patience.
EE-Sample_CompareSheets-_B_V2.xlsm
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you - I believe this gets me closer.
You're welcome!
Place this sub routine on a Standard Module...
Open in new window
And then call it within your main macro whenever required like below...Open in new window