strange result - Nested IF statement

CodyMonster

Board Regular
Joined
Sep 28, 2009
Messages
153
ABCDEFGH
Reporting DateInvoice IDinvoice payment idinvoice header idinvoice terms datevendor numberpo/non-po flagsupplier name
23-Apr-201900057573_5430_2020_00010640771900057573_5430_20200001064077NON_POGT TRANSPORT 2012 CO LTD
23-Apr-201900264963_6070_2020_00010584941900264963_6070_20200001058494NON_PONES GLOBAL TALENT RECRUITMENT SERVI
23-Apr-200027002369_6400_2020_00055080650027002369_6400_2020_00055080654/16/20200005508065POLUSH (HEAT TREATMENT) LTD
23-Apr-201900004280_L410_2020_1900004280_L410_20204/13/2020NON_PO0000315509

I'm getting the strangest result for the below nested if statement in "B". For some reason the statement doesn't pick up the supplier name if the vendor number "F" is blank.
I get D and the _ between the two cell references (D9 and H9) but not the number in column H.

=IF(AND(C9="",LEN(D9)<=20),D9&"_"&F9, IF(AND(C9="",F9=""),D9&"_"&H9,D9))

does anyone have an idea? I bet its something simple and I've been looking at this too long!
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
12,620
Office Version
  1. 2007
Platform
  1. Windows
This part of your formula is true

IF(AND(C9="",LEN(D9)<=20),D9&"_"&F9

C9 = "" and LEN(D9) = 20, so : D9&"_"&F9
Then 1900004280_L410_2020 " & "_" & (blank)
 

CodyMonster

Board Regular
Joined
Sep 28, 2009
Messages
153
This part of your formula is true

IF(AND(C9="",LEN(D9)<=20),D9&"_"&F9

C9 = "" and LEN(D9) = 20, so : D9&"_"&F9
Then 1900004280_L410_2020 " & "_" & (blank)

Thanks Dante,
Found something that worked.

=IF(AND(C8="",LEN(D8)<=20,F8<>""),D8&"_"&F8, IF(AND(C8="",LEN(D8)=20),D8&"_"&H8,D8))
 

Watch MrExcel Video

Forum statistics

Threads
1,129,539
Messages
5,636,903
Members
416,949
Latest member
propertyscout

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