I have this Google sheet:
I am using this formula to split my strings in columns
=ARRAYFORMULA(IFERROR(IF(D2:D=1, SPLIT(A2:A, "+"), SPLIT(C2:C, "+"))))
Molecules ID NAME Vitamin_in_name NAME1 NAME2 NAME3
VITAMIN B1 + VITAMIN B6 + VITAMIN B12 1 VITAMIN B1,B6,B12 1 VITAMIN B1 VITAMIN B6 VITAMIN B12
2 LIDOCAINE + VITAMIN B4,B8,B10 1
3 SALICYLIC ACID + TALC 0 SALICYLIC ACID TALC
I would like to return this sheet. IF the word "vitamin_in_name" = 1 and "molecules" row is empty to re-format the data like in ID2 Column name1, name2, name3. how can i do modify my array formula to do that?
Molecules ID NAME Vitamin_in_name NAME1 NAME2 NAME3 NAME4
VITAMIN B1 + VITAMIN B6 + VITAMIN B12 1 VITAMIN B1,B6,B12 1 VITAMIN B1 VITAMIN B6 VITAMIN B12
2 LIDOCAINE + VITAMIN B4,B8,B10 1 LIDOCAINE VITAMIN B4 VITAMIN B8 VITAMIN B10
3 SALICYLIC ACID + TALC 0 SALICYLIC ACID TALC