That is not what you asked.

"generate a flowchart in excel by writing some code with some if and for loops??"

If *you* write the code then yes it is possible.