I see two issues with the logic here. I would need more information before knowing if it could be simplified further.
First, I see that every IF statement in the red part includes the condition HOURLYSW2PI!D2>0. That means this can be factored out as an IF up front, instead of repeated in every IF, like this:
=IF(OR('Payroll detail report'!E2="REGLAR",HOURLYSW2PI!D2=0),'Payroll detail report'!G2,IF(HOURLYSW2PI!D2>0,IF('Payroll detail report'!E2="GRAVE1",'Payroll detail report'!G2,IF('Payroll detail report'!E2="GRAVE2",'Payroll detail report'!G2,IF('Payroll detail report'!E2="GRAVE3",'Payroll detail report'!G2,IF('Payroll detail report'!E2="SCHED",'Payroll detail report'!G2,IF('Payroll detail report'!E2="LEAD",'Payroll detail report'!G2,IF('Payroll detail report'!E2="OPI",'Payroll detail report'!G2,""))))))))
Further, the outcome of every IF condition you check is 'Payroll detail report'!G2. It might be easier to check for the condition that would result in a blank, rather than checking every condition that would result in 'Payroll detail report'!G2. But I can't tell without more information.
There may be a better way to write this formula if I knew what you were trying to do, but based on pure logic alone this is the simplest I can get using the same general approach. It uses a single AND to group together those checks, instead of a separate IF for each possible value:
=IF(OR('Payroll detail report'!E2="REGLAR",HOURLYSW2PI!D2=0, AND(HOURLYSW2PI!D2>0,OR('Payroll detail report'!E2="GRAVE1",'Payroll detail report'!E2="GRAVE2",'Payroll detail report'!E2="GRAVE3",'Payroll detail report'!E2="SCHED",'Payroll detail report'!E2="LEAD",'Payroll detail report'!E2="OPI", 'Payroll detail report'!G2))),"")
Here is a logical equivalent that gets a little bit tricky, and this is the shortest one you will get out of me. It uses MATCH to see if E2 is one of the possible values, rather than a long OR which requires the cell address to be used in a comparison for each possibility:
=IF(OR('Payroll detail report'!E2="REGLAR",HOURLYSW2PI!D2=0, AND(HOURLYSW2PI!D2>0,NOT(ISERROR(MATCH('Payroll detail report'!E2,{"GRAVE1","GRAVE2","GRAVE3","SCHED","LEAD","OPI"},0))))), 'Payroll detail report'!G2,"")
Bookmarks