How to assign zero to empty cell in excel

I’m Creating PIVOT Table from an Excel Sheet and some of the columns are empty, i want this particular cell to assign zero.
I used For Each Row and used If condition : CurrentRow(“Direct”).ToString.Contains("")
Assign : CurrentRow(“Direct”) = “0”, it’s not working ?? can you help with other option ?

1 Like

Try CurrentRow(“Direct”).toString isNothing

Regards :slight_smile:

Hi @Sudhir_P

CurrentRow(“YourColumnname”).ToString is Nothing in If Condition

Or String.isNullOrEmpty(CurrentRow(“YourColumnname”).ToString) expression

Then assign

Current(“YourColumnname”) =“0”

Regards

Hi

You are almost done

Just a small change in your condition

Hope the below steps would help resolve this

  1. Let’s take like you have the datatable named as dt
  2. Now use a FOR EACH ROW activity and pass dt as input
  3. Inside the loop use a IF activity with condition like this

String.IsNullOrEmpty(CurrentRow(“Direct”).ToString.Trim)

If true it will go to Then block where use a assign activity like this

CurrentRow(“Direct”) = “0”

That’s all

Cheers @Sudhir_P

thank you for all your replies, the condition is working, it’s going into “then” condition but not writing the value, do we need to use “write Cell” activity or “Write Range” ?

@Sudhir_P

Then
Assign Activity Currentrow(“YourColumnName”) =“0”

Out side the for each loop

Write range as same as Read range Path and Datatable
Check the add Headers properties!

Regards

thank you very much

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