イメージ的にはこんな感じで IF:CELL(Current-1,Current+1)>200 CELL(Current-1,Current+1)=0 SET Val=ExcelSql(select * from hoge) ELSE: CELL(Current-1,Current+1)= CELL(Current-1,Current+1)+1 SET Val=ExcelSql(select * from hoge2) ENDIF: SetBackColor(Current-1,Current+1,Red)