Excel Condition

Hi All,

I have stucked in a issue that.
There is a condition like :
“Credit_Debit_match.Contains(“D”)>Credit_Debit_match.Contains(“C”) Or Credit_Debit_match.Contains(“C”)>Credit_Debit_match.Contains(“D”)”
then I want to write a value 0(Zero) at end of an excel in last row where the credit and debit column contains.

I.e if an excel contains 49 rows I want to write a row below 49th row
i.e. in 50th row with the values “0” when the above specified condition is matched.

Please suggest me how to do that.

Book1243.xlsx (15.8 KB

Please find the attachment which contains data before matching and after matching the condition in two different sheets.

Please help me


It’s invalid condition. Can you please tell more details about your Usecase.

Hi @HeartCatcher

As @lakshman said it is invalid condition. You can’t check directly DT.Contains(“D”)

  • You can use for each row in DataTable
    Row("Debit / Credit Code").ToString.Contains("D")>Row("Debit / Credit Code").ToString.Contains("C")Or Row("Debit / Credit Code").ToString.Contains("C")>Row("Debit / Credit Code").ToString.Contains("D")



The thing is there is column “Debit / Credit Code”
which contains “C”(Credit) and “D”(Debit) both the “C” and “D” should be same
i.e if “C” is present for 14 times then “D” also present for 14 times.
If both are not equal then I need to put the condition like above after that I need to write a whichever is less(Suppose “D”) is less then I need to add “D” in ““Debit / Credit Code”” to match the “C” “D” and in the amount columns need to mention "0"for extra added “D”.

Please help me on this.

In Short I am trying to matching the credit and debit legs

Then if the condition is matched I wanna write a line after last row with the value “0”.
please let me know its urgent

in case of the check should be done over all rows from datatable the condition has to be adopted
Also we would recommend to work with:

  • count
  • Math.Abs

within the condition