Any one can help me create a vba function with excel IF, INDEX, MATCH function as follows ;
=IF(INDEX(Grid!$B$3:$G$6,MATCH('Sal-Data'!$A2,Grid!$A$3:$A$6,0),MATCH('Sal-Data'!$B2+1,Grid!$B$2:$G$2,0))=0,$B2,$B2+1)
You can call function as NGrid.
Function NGrid (....... )
code ........... ' please enter VBA coding
excel sheet name : Grid
[TABLE="width: 364"]
<tbody>[TR]
[TD][/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]2[/TD]
[TD="align: right"]3[/TD]
[TD="align: right"]4[/TD]
[TD="align: right"]5[/TD]
[TD="align: right"]6[/TD]
[/TR]
[TR]
[TD]a[/TD]
[TD="align: right"]10[/TD]
[TD="align: right"]11[/TD]
[TD="align: right"]12[/TD]
[TD="align: right"]13[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[/TR]
[TR]
[TD]b[/TD]
[TD="align: right"]20[/TD]
[TD="align: right"]21[/TD]
[TD="align: right"]22[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[/TR]
[TR]
[TD]c[/TD]
[TD="align: right"]30[/TD]
[TD="align: right"]31[/TD]
[TD="align: right"]32[/TD]
[TD="align: right"]33[/TD]
[TD="align: right"]34[/TD]
[TD="align: right"]0[/TD]
[/TR]
[TR]
[TD]d[/TD]
[TD="align: right"]40[/TD]
[TD="align: right"]41[/TD]
[TD="align: right"]42[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[/TR]
</tbody>[/TABLE]
excel sheet name : Sal-Dat
[TABLE="width: 138"]
<tbody>[TR]
[TD][/TD]
[TD]grid[/TD]
[TD]New grid[/TD]
[/TR]
[TR]
[TD]a[/TD]
[TD="align: right"]4[/TD]
[TD] =NewGrid()[/TD]
[/TR]
[TR]
[TD]a[/TD]
[TD="align: right"]2[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]b[/TD]
[TD="align: right"]1[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]b[/TD]
[TD="align: right"]2[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]c[/TD]
[TD="align: right"]1[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]c[/TD]
[TD="align: right"]5[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]c[/TD]
[TD="align: right"]4[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]d[/TD]
[TD="align: right"]2[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]d[/TD]
[TD="align: right"]3[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
=IF(INDEX(Grid!$B$3:$G$6,MATCH('Sal-Data'!$A2,Grid!$A$3:$A$6,0),MATCH('Sal-Data'!$B2+1,Grid!$B$2:$G$2,0))=0,$B2,$B2+1)
You can call function as NGrid.
Function NGrid (....... )
code ........... ' please enter VBA coding
excel sheet name : Grid
[TABLE="width: 364"]
<tbody>[TR]
[TD][/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]2[/TD]
[TD="align: right"]3[/TD]
[TD="align: right"]4[/TD]
[TD="align: right"]5[/TD]
[TD="align: right"]6[/TD]
[/TR]
[TR]
[TD]a[/TD]
[TD="align: right"]10[/TD]
[TD="align: right"]11[/TD]
[TD="align: right"]12[/TD]
[TD="align: right"]13[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[/TR]
[TR]
[TD]b[/TD]
[TD="align: right"]20[/TD]
[TD="align: right"]21[/TD]
[TD="align: right"]22[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[/TR]
[TR]
[TD]c[/TD]
[TD="align: right"]30[/TD]
[TD="align: right"]31[/TD]
[TD="align: right"]32[/TD]
[TD="align: right"]33[/TD]
[TD="align: right"]34[/TD]
[TD="align: right"]0[/TD]
[/TR]
[TR]
[TD]d[/TD]
[TD="align: right"]40[/TD]
[TD="align: right"]41[/TD]
[TD="align: right"]42[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]0[/TD]
[/TR]
</tbody>[/TABLE]
excel sheet name : Sal-Dat
[TABLE="width: 138"]
<tbody>[TR]
[TD][/TD]
[TD]grid[/TD]
[TD]New grid[/TD]
[/TR]
[TR]
[TD]a[/TD]
[TD="align: right"]4[/TD]
[TD] =NewGrid()[/TD]
[/TR]
[TR]
[TD]a[/TD]
[TD="align: right"]2[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]b[/TD]
[TD="align: right"]1[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]b[/TD]
[TD="align: right"]2[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]c[/TD]
[TD="align: right"]1[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]c[/TD]
[TD="align: right"]5[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]c[/TD]
[TD="align: right"]4[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]d[/TD]
[TD="align: right"]2[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]d[/TD]
[TD="align: right"]3[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]