Hi there,
Option1
here are the formulas you can insert and autofill. the disadvantage of this option is you have to know the last cell position with data.
Results:
=IF(OR(C2<35, D2<35, E2<35, F2<35, G2<35, H2<35), "Fail", "Pass")
Grade:
=IF(I2>500, "A", IF(I2>=360, "B", "C"))
Count of the Failed Subject:
=SUM(IF(C2<35, 1, 0), IF(D2<35, 1, 0), IF(E2<35, 1, 0), IF(F2<35, 1, 0), IF(G2<35, 1, 0), IF(H2<35, 1, 0))
Count of the Passed Subject:
=SUM(IF(C2>=35, 1, 0), IF(D2>=35, 1, 0), IF(E2>=35, 1, 0), IF(F2>=35, 1, 0), IF(G2>=35, 1, 0), IF(H2>=35, 1, 0))
Rank:
=RANK.EQ(I2, $I$2:$I$10, 0)
Option2
Read your Excel data into a datatable eg dt and then use LINQ to fill the values:
–Linq-1 (calculates all excepts ranking)
From row In dt.AsEnumerable()
Select New With {
.StudentName = row.Field(Of String)("StudentName"),
.RollNumber = row.Field(Of Integer)("RollNumber"),
.Result = If(row.Field(Of Integer)("Total") < 210, "Fail", "Pass"),
.Grade = If(row.Field(Of Integer)("Total") < 360, "C",
If(row.Field(Of Integer)("Total") < 501, "B", "A")),
.CountOfFailedSubject = (From mark In row.ItemArray.Skip(2)
Where CInt(mark) < 35 Select mark).Count(),
.CountOfPassedSubject = (From mark In row.ItemArray.Skip(2)
Where CInt(mark) > 35 Select mark).Count(),
.Total = row.Field(Of Integer)("Total"),
.Percentage = CDec(row.Field(Of Integer)("Total")) / 600 * 100,
.Rank = 0 ' We'll calculate this later
}
Linq-2 Calculates the ranking:
s
dt.Select(Function(s) s With {.Rank =
(From prev In students.TakeWhile(Function(p) p IsNot s)
Select prev.Total).DefaultIfEmpty().Max() + 1}})
Now you can write range into the same sheet if you want, it will overwrite old data with new data and the calculations, this is much simpler and you do not have to know the range upfront