Inserting Text Into an IF Statement

Hoosier03

Board Regular
Joined
Apr 29, 2011
Messages
121
I am using Excel 2007.

I have two lookups that are referencing two workbooks. The problem I have is the numbers in my workbooks are different. They are in regular text. The numbers in the other workbook all have a ' sign in front of them. For example my workbook has 1004. The other workbook has '1004. I cannot change the numbers in either workbook. Is there a way I can create a lookup that inserts the ' if the number is numerical? Not all the numbers have the problem. The ones that start with text, like
AR132509BB1 are fine.

<tbody>
</tbody>


Any thoughts?

Thanks,

Rodney
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.

Mike LH

Well-known Member
Joined
Mar 17, 2015
Messages
566
Hi,

you can do it like my vlookup below. Note I coerced the lookup value of 1004 into text by concatenating a null string.


=VLOOKUP(""&A2,I2:J23,2,FALSE)
 

bbott

Well-known Member
Joined
Feb 5, 2010
Messages
2,350
That's because the number in your workbook is stored as a number, but the number with the ' is stored as text. You can make your look up value text like so:

=VLOOKUP(""&1004,A1:B3,2,0)

Does that help?
 

Hoosier03

Board Regular
Joined
Apr 29, 2011
Messages
121
Sorry I was not more clear on this, but the lookup function is INDEX MATCH. VLOOKUP won't work in this situation.

Thanks,

Rodney
 

bbott

Well-known Member
Joined
Feb 5, 2010
Messages
2,350

ADVERTISEMENT

The same concept will still apply. What is the formula that you're using now?
 

Hoosier03

Board Regular
Joined
Apr 29, 2011
Messages
121
=INDEX('[Item Listing with Product Detail.xlsx]ITEM LISTING WITH PRODUCT LINE'!$A$3:$A$50901, (MATCH(A3, '[Item Listing with Product Detail.xlsx]ITEM LISTING WITH PRODUCT LINE'!$B$3:$B$50901, 0)))

Also note that not all of the returns need the ' symbol in front of them. The ones that begin with letters do not need this just the ones that begin with numbers.

Thanks,

Rodney
 

bbott

Well-known Member
Joined
Feb 5, 2010
Messages
2,350

ADVERTISEMENT

Try:

=INDEX('[Item Listing with Product Detail.xlsx]ITEM LISTING WITH PRODUCT LINE'!$A$3:$A$50901, (MATCH(""&A3, '[Item Listing with Product Detail.xlsx]ITEM LISTING WITH PRODUCT LINE'!$B$3:$B$50901, 0)))
 

svendiamond

Well-known Member
Joined
Jun 13, 2014
Messages
1,504
Office Version
  1. 365
Platform
  1. Windows
You just need a condition for your lookup value.

=INDEX('[Item Listing with Product Detail.xlsx]ITEM LISTING WITH PRODUCT LINE'!$A:$A,MATCH(IF(ISNUMBER(A3),"'"&A3,A3),'[Item Listing with Product Detail.xlsx]ITEM LISTING WITH PRODUCT LINE'!$B:$B,0))
 

bbott

Well-known Member
Joined
Feb 5, 2010
Messages
2,350
You just need a condition for your lookup value.

=INDEX('[Item Listing with Product Detail.xlsx]ITEM LISTING WITH PRODUCT LINE'!$A:$A,MATCH(IF(ISNUMBER(A3),"'"&A3,A3),'[Item Listing with Product Detail.xlsx]ITEM LISTING WITH PRODUCT LINE'!$B:$B,0))

The condition is not necessary. Adding the null string will convert any numbers to text and won't affect data that is already text.
 

svendiamond

Well-known Member
Joined
Jun 13, 2014
Messages
1,504
Office Version
  1. 365
Platform
  1. Windows
It's not null... it's " ' " << notice the little apostrophe in between... just adding an apostrophe before the number to match what's on the other workbook.
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,881
Messages
5,834,226
Members
430,267
Latest member
Excel_User_4

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
Top