I am stuck with my automation project below is the problems encountered..please help...

I have loaded the data to an excel file from the server.
Now is the problem in processing the data.
I have checked all the rows from first to last row to find whether the fifth and the third column is repeated...if repeated that is the same values (for 3rd and 5th column) are seen in different rows of the sheet..i have brought it forward to another sheet... (done using for..loop)

now below is the problem i face( which i do not knw how to do)

Now in the new sheet with same values i have to do the judging for two other columns in the same row..for eg: the column 7 and column eight..
if column 7 have values like X,G,O. I have to give priority only to X..the rest all rows in that sheet is useless data then.
And if more than one row with X is present then i have to check for column 8 for the rows with X value
if column 8 value is greater for one row then i have to take only that row values and put it to another sheet.

Somebody please help me thank you.