Multiple IF statements in single column

Afro_Cookie

Board Regular
Joined
Mar 17, 2020
Messages
103
Office Version
  1. 365
Platform
  1. Windows
I am starting a defect log that will catalogue multiple item classes (4 so far) and I want to group their part numbers into a single column.
I can write a nested If statement that will do the calculations I need to pull data from other reference files, but it's ugly and if someone messes with the code, it will affect a lot of data.
Is there a way in VBA to write a statement that will pull relevant data from different files, depending on the value in a single column?

Examples
VBA Code:
=IF(COUNTIF(C2,"L*"),"YES",XLOOKUP($C2,'database'!$A$1:$A$65536,'database'!$Q$1:$Q$65536))

DateFormulaItem #
1-Jan-222108009C26440721
2-Jan-22YESLAB12645
3-Jan-22YESLAB12345
4-Jan-222106011C26393028
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
So as an update. I've populated a large IFS() statement but left out the references to other files I'd have to pull to make it work. The formula is long and ugly, but functional. Can someone think of a cleaner solution either in vba or directly in my sheet?

"Sticker", "Lid", "Box", "Number" will all be replaced with references to other workbooks and sheets to pull the correct data.

Defect Report playground.xlsm
BC
1AB
2Number1
3StickerLab
4BoxCON
5LidLID
Data
Cell Formulas
RangeFormula
B2:B5B2=IFS(COUNTIF(C2,"LAB*"),"Sticker",COUNTIF(C2,"LI*"),"Lid",COUNTIF(C2,"CON*"),"Box",C2>0,"Number")
 
Upvote 0

Forum statistics

Threads
1,215,753
Messages
6,126,677
Members
449,327
Latest member
John4520

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
Back
Top