Combine If statements

mbetsy

New Member
Joined
Aug 3, 2015
Messages
13
Happy New Year and thank you in advance.

I have 3 if statements which work individually but I don't do semi complex formula writing often enough to know how to do this properly.

If A1 is blank then concatenate this way, concatenate that way
If A1 is not blank and B1 is blank, then concatenate this way, concatenate that way
If A1 is not blank and B1 is not blank, then concatenate this way, concatenate that way

My concatenate formulas don't seem toe be the issue, true and false in a response would be understood.

Tks.
 

Some videos you may like

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
38,496
Office Version
365
Platform
Windows
Something along the lines of
=IF(A1="","a1 is blank",IF(B1="", "a1 is not blank & b1 is blank","neither a1 nor b1 are blank"))
 

mbetsy

New Member
Joined
Aug 3, 2015
Messages
13
Here are the 3 statements which work individually, which I would like to combine:

C1D1E1F1G1
=IF(ISBLANK(A2),IF(ISBLANK(B2),CONCATENATE(C1,G1),CONCATENATE("not what i want")))
A3=IF(NOT(ISBLANK(A3)),IF(ISBLANK(B3),CONCATENATE(C1,F1,G1),CONCATENATE("not what i want")))
A4B4=IF(NOT(ISBLANK(A4)),IF(ISBLANK(B4),CONCATENATE(C1,D1,E1,F1,G1),CONCATENATE("not what i want")))

<tbody>
</tbody>







Thank you.
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
38,496
Office Version
365
Platform
Windows
Can you show the expected outcome for each scenario?
 

mbetsy

New Member
Joined
Aug 3, 2015
Messages
13
Thank you for sticking with me, Fluff.

C1D1E1F1G1
Desired Result: C1 G1
A3Desired Result: C1 F1 G1
A4B4Desired Result: C1 E1 F1 G1

<tbody>
</tbody>







Essentially, depending on the blank status of either A or B, pick up a different set of cells to concatenate. The three rules represent the 3 possible scenarios for my data.

/mbetsy
 

bosco_yip

Well-known Member
Joined
Dec 2, 2002
Messages
1,938
Office Version
2019
Platform
Windows
Maybe,

In C2, copied down :

=CHOOSE(BIN2DEC(0+(A2<>"")&0+(B2<>""))+1,C$1&" "&G$1,"not what i want",C$1&" "&F$1&" "&G$1,C$1&" "&E$1&" "&F$1&" "&G$1)

Regards
Bosco
 

mbetsy

New Member
Joined
Aug 3, 2015
Messages
13
Thank you, bosco. That does yield close to the desired result; adds an extra space between the cells. I have looked up the bin2dec function, but have had no occasion to use it. Can you explain the logic of the solution? Tks.
 

bosco_yip

Well-known Member
Joined
Dec 2, 2002
Messages
1,938
Office Version
2019
Platform
Windows
Extract the BIN2DEC function part form the formula >>

>> BIN2DEC(0+(A2<>"")&0+(B2<>""))+1

This part >> 0+(A2<>"")&0+(B2<>"") generate 00, 01, 10 or 11

Then,

BIN2DEC(0+(A2<>"")&0+(B2<>""))+1 will give result 1, 2, 3 or 4 (being the Index number of the Choose function)

Regards
Bosco
 

mbetsy

New Member
Joined
Aug 3, 2015
Messages
13
So the formula creates a value for an empty cell, then gives each permutation a unique value, and gives each permutation directions?

I have now successfully integrated this into my work, thank you very much.
 

Watch MrExcel Video

Forum statistics

Threads
1,095,234
Messages
5,443,273
Members
405,222
Latest member
Summer01

This Week's Hot Topics

  • Copy entire row if CountA <>0 to another sheet
    [B]I want to copy entire row if CountA <>0 for column J7:AM7 (headers on J6:AM6) and so on till the last used cell is column D and paste the...
  • Select last used Row in Table
    I have created a Table in a Worksheet which is locked to prevent user errors and protect formula. Some of the cells require freetext entries which...
  • excel workbook: do not allow certain file name
    Hello all, Don't think this has ever been asked before, but how do I restrict file save [Before_Save Event] if the name of the file being saved...
  • fixing problem autofilter
    hello i need help about my code when i search by code in textbox it doesn't show anything this is my data [ATTACH type="full"...
  • “Weight”
    Hi, i’ve got a long sheet filled with weights such as kg,g,L & ml. i can build a formula to convert kg into g and liter into ml. How ever, my...
  • How to capitalize everything before a certain character?
    In column A, I have some text: Hello good day.mp3 Hello good day.flac etc. I'd like to capitalize everything before the period. I don't need the...
Top