PDA

View Full Version : Code to Compare Cell Contents



AndresH
02-14-2013, 01:23 PM
Hello everyone,

I am a beginner to VBA and I'm having some trouble with this. What I want to do is have a button that when clicked it will compare rows to see if the contents of the rows are equal, this is something I have to do every day and I want to make it a bit less manual.

This is how it would work: I have some entries from cells A5 to G5, all of these are part of the same record (say Name, Address, Phone number, SIN, etc.), then I have some entries on cells I5 to O5, and I have to compare if each of these match (i.e. check if A5 matches I5, if B5 matches J5, etc. until G5 and O5). If they all match then the word "OK" should show up from cells Q5 to W5, each of these corresponding to the previous cells (so if A5 matches I5, "OK" would show up in Q5), and then I need to move to the other records below (A6:G6) and follow the same process.

However, if all the info from the first set (A:G) does not match the info in the second set (I:O) then I have to cut all the information and paste it in the row below and compare it to the row next to it (So if the information from A5:G5 does not completely match the info in I5:O5, I would need to cut all the information from A5:G5, and everything below it, and now compare it to the info in I6:O6 and everything else below it). This process should continue until a blank row is reached in the I:O column set.

So I want to create a button that I can just click and would do all of this automatically instead of always doing the entire process manually. I would appreciate any help I could receive regarding this!

Thank you!

PS: Below I've included a picture of what the table roughly looks like.

//i(dot)imgur(dot)com/PtJWEMd(dot)png