Hello prashanth0523 and Welcome to Excel Forum.
As for work from home this month paste the following into NJ8 and then copy down to NJ27:
Formula: copy to clipboard
=SUMPRODUCT((OFFSET($A8,0,31*($A$3-1)+1,1,31)=NR$5)*(OFFSET($A$4,0,31*($A$3-1)+1,1,31)))

As for work from home this year paste the following into NJK8 and then copy down to NK27:
Formula: copy to clipboard
=SUMPRODUCT((OFFSET($A8,0,1,1,372)=NX$14)*(OFFSET($A$3,0,1,1,372)))

I am not sure what you mean by exclude work from home count from leave in this month and leave in this year. Please give us a specific column or row that should be changed.
Let us know if you have any questions.