How to use increment method in Excel

excel
activities

#1

I have excel that I need process where the some record fails and some passes I need to increment both failure as well as passed records.
ex:

qwe-Pass
asd-Fail
wer-Fail
sdgf- Pass
kfnk-fail

Result should be
Failed records-3
Pass records-2


#2

Hi,

Have you tried using an If condition and Assign inside a ForEach loop?

Basically, you would do this…
Read Range
ForEach row In datatable
If row(1).Item.ToString.Trim.ToUpper = “FAIL” then Assign nFailed = nFailed+1
elseIf row(1).Item.ToString.Trim.ToUpper = “PASS” then Assign nPassed = nPassed+1

Alternatively, you can run a vb.net expression to an array and use .Count without using a For loop
Read Range
Assign nFailed = datatable.AsEnumerable().Where(Function(row) row(1).ToString.Trim.ToUpper = “FAIL”).ToArray().Count
Assign nPassed = datatable.AsEnumerable().Where(Function(row) row(1).ToString.Trim.ToUpper = “PASS”).ToArray().Count

Regards.