Taking first 3 characters from a cell A1 and comparing it to a range. If there's a match, the three characters from A1 go to B1.

apace

New Member
Joined
Jun 28, 2021
Messages
8
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
I am trying to compare the first three characters in A1 with a range from C1 to C100. If there is a match, the first three characters would copy to B1.
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
=COUNTIF(C1:C100,LEFT(A1,3)&"*")
will count if the left 3 characters in A1 are the starting 3 characters in column C
if thats the match - OR is it ANY where in the text

then an IF in B1 to copy the 3 characters
=IF(COUNTIF(C1:C100,LEFT(A1,3)&"*")>0,LEFT(A1,3),"")
 
Upvote 0
Should the first 3 characters from A1 be all that is found in column C, the first part of a longer string, or any part of a string?

For an exact match
Excel Formula:
=IFERROR(VLOOKUP(LEFT(A1,3),C1:C100,1,0),"No Match")
For the first part of a longer string in column C
Excel Formula:
=IF(COUNTIF(C1:C100,LEFT(A1,3)&"*"),A1,"No Match")
For anywhere in a string found in column C
Excel Formula:
=IF(COUNTIF(C1:C100,"*"&LEFT(A1,3)&"*"),A1,"No Match")
 
Upvote 0
=COUNTIF(C1:C100,LEFT(A1,3)&"*")
will count if the left 3 characters in A1 are the starting 3 characters in column C
if thats the match - OR is it ANY where in the text

then an IF in B1 to copy the 3 characters
=IF(COUNTIF(C1:C100,LEFT(A1,3)&"*")>0,LEFT(A1,3),"")
That's perfect, thank you for the help!
 
Upvote 0

Forum statistics

Threads
1,224,819
Messages
6,181,153
Members
453,021
Latest member
Justyna P

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