Excel formular question

@mkankatala please go to Write cell issue if no data
there has sth wrong with the formular if the sheet contain no data, thanks for your help!!