# Inserting Text Into an IF Statement

#### Hoosier03

##### Board Regular
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

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
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)

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?

Sorry I was not more clear on this, but the lookup function is INDEX MATCH. VLOOKUP won't work in this situation.

Thanks,

Rodney

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

=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

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)))

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))

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.

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.

Replies
1
Views
68
Replies
11
Views
260
Replies
1
Views
289
Replies
3
Views
137
Replies
4
Views
140

1,203,128
Messages
6,053,674
Members
444,678
Latest member
Kenny_D

### 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.

### Which adblocker are you using?

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

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