Compare data in two columns [Closed]

Report
-
 Blocked Profile -
Hello,

Q 4 U - pls and thank you

CCC=characters/letters
NNN=numerics

Trying to compare these two columns and identify partial matches between Column A and B where Column B has a dash abc after the numeric

Column A cccnnnnn
Column B cccnnnnn-abc

1 reply

Very simply:

dim thefirstvalue
dim thesecondvalue

thefirstvalue = thisworkbook.worksheets("sheet1").range("A1").value
thesecondvalue = thisworkbook.worksheets("sheet2").range("A1").value

if thefirstvalue = thesecondvalue then
'do something great here!!!
end if



Have FUN!

P.S-You have a multi-step answer here, because you are also wanting to PARSE the value. It is a SPLIT command. As in:

thevariable = "cccnnnnn-abc"
Splitvariable = Split(thevariable,"-")
'now you look at the delimited value in an array of splitvariable, as in
msgbox(Splitvariable(1)) ' returns abc


If the above is confusing, you need to read arrays! But simply, the command of SPLIT can check for delimitors, and parse them. In this case, we have told SPLIT to use the "-" as the delimiter (because your variable has it in the part number). You can omit the delimiter, in which case it will find SPACES!

Subscribe To Our Newsletter!

The Best of CCM in Your Inbox

Subscribe To Our Newsletter!