Excel condition14

Hi All,

I have an output excel which will generate after running the macro.
In a column “Credit/Debit” contains the value “C”(credit) and “D”(Debit).
the “C” and “D” should be same.
But in my case “C” contains for 20 times and "D"19 times.
I need a condition to write the “D” for one time to match the 20 records with “C” and i need to assign value “0” in credit amount column and “0” in debit account column(this condition only if there is difference between “C” and “D”)
Someone please guide me on this.
i.e if “C” presents for 20 times “D” also presents for 20times.


please refer the screenshot for the reference

@geetishree.rao
@Palaniyappan
@ppr
@ganta.lakshman143
@lakshman

1 Like

Hi

Hope the below steps would help you resolve this

  1. First use a read range activity and get the output as datatable dt

  2. Let’s find the number of rows in C and D column individually

Int_crows = (From row in dt.AsEnumerable() Select Convert.Tostring(row(“C-ColumnName”))).ToList().Count

Mention C column name of your table

Similarly for D column

Int_drows = (From row in dt.AsEnumerable() Select Convert.Tostring(row(“D-ColumnName”))).ToList().Count

Where int_crows and int_drows are int32 type of variable

  1. Now use a IF condition like this

int_crows.Equals(int_drows)

If true it will go to THEH block where leave it empty and if false go to ELSE where use the below set of assign activity

dt.Rows(dt.Rows.Count)(“credit amount”) = “0”

Another assign activity

dt.Rows(dt.Rows.Count)(“Debit account”) = “0”

Cheers @HeartCatcher

2 Likes

Thanks buddy @Palaniyappan.
You are really a master in uipath

1 Like

Hi @Palaniyappan,
What if both “credit” and “debit” values columns are in same column at that time how could we put the condition for the same(you have done for two separate individual column), sometime data will be in single column rather than separate.
Please guide me in this.

Can I see a screenshot of how it looks in single column
@HeartCatcher


Debit/Credit code(Column name)

Here C refers for credit and D for debit (in H column)

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.