PDA

View Full Version : Compare the value with different name.



jackwong730
03-03-2016, 08:42 AM
Just want to compare "A_Group" with "B_Group", to find out if the values in "A_Group" can match the definition.
Can do it without the definition (that would be better.)
Do it in either in Excel only or with VBA.
Thanks!!


15538 <--Raw Data
15539 <-- the definition
15540 <- the expected result

williedog
03-03-2016, 09:44 AM
Something like:


Sub CompareValues()
Range("C1") = "Match"
Range("C2").Select
With Selection
.Formula = "=IF(OR(AND(RC[-2]=""High"",RC[-1]=""1-Urgent""),AND(RC[-2]=""Normal"",RC[-1]=""2-Normal""),AND(RC[-2]=""Low"",RC[-1]=""3-Low"")),""Match"",""Not Match"")"
.AutoFill Destination:=Range("C2:C" & Cells(rows.Count, "A").End(xlUp).Row)
End With
End Sub

Do you have an A_Group value for the B_Group value of 4-None? Also, will the values always be what you have or could there be a misspelling, like Higg instead of High or 1-Urgenr instead of 1-Urgent?

jackwong730
03-03-2016, 05:49 PM
Yes, it does.
The speeling would not be wrong.

williedog
03-04-2016, 09:08 AM
Then replace this line


.Formula = "=IF(OR(AND(RC[-2]=""High"",RC[-1]=""1-Urgent""),AND(RC[-2]=""Normal"",RC[-1]=""2-Normal""),AND(RC[-2]=""Low"",RC[-1]=""3-Low"")),""Match"",""Not Match"")"

with this line


.Formula = "=IF(OR(AND(RC[-2]=""High"",RC[-1]=""1-Urgent""),AND(RC[-2]=""Normal"",RC[-1]=""2-Normal""),AND(RC[-2]=""Low"",RC[-1]=""3-Low""), AND(RC[-2]=""whatever"",RC[-1]=""4-None"")),""Match"",""Not Match"")"

In the new code line, replace the word whatever with the word that matches up with 4-None.

jackwong730
03-14-2016, 07:32 AM
Thanks! It works