=IF($X3>0,"Not Required",XLOOKUP(-$X3,SCAN(0,$A3:$W3,LAMBDA(a,b,a+b)),$A$2:$W$2,"Need to order",1))
=IFERROR(IF($X3<0,SUM(OFFSET($A3,0,0,,XMATCH(-$X3,SCAN(0,$A3:$W3,LAMBDA(a,b,a+b)),1))),""),"")
In a cell in row 3:
In another cell in row 3:Code:=IF($X3>0,"Not Required",XLOOKUP(-$X3,SCAN(0,$A3:$W3,LAMBDA(a,b,a+b)),$A$2:$W$2,"Need to order",1))
See attached in columns AB & AC.Code:=IFERROR(IF($X3<0,SUM(OFFSET($A3,0,0,,XMATCH(-$X3,SCAN(0,$A3:$W3,LAMBDA(a,b,a+b)),1))),""),"")