How I input value in bank cell on excel table?

I have excel table that some cell is bank. So, I would like to input ‘0’ in bank cell.
Hope to receive suggestion from you all.
As of now, I use invoke vba to slove this problem.
However, I would like to use another UiPath activity.

P.S. I use UiPath studio-x version.
P.S. I attach vba code for your reference.

Sub FillEmptyCellsInTableWithZero()

  • Dim ws As Worksheet*

  • Dim tbl As ListObject*

  • Dim cell As Range*

  • Set ws = ThisWorkbook.Sheets(“Summary”)*

  • Set tbl = ws.ListObjects(1) *

  • For Each cell In tbl.DataBodyRange*

  •    If IsEmpty(cell.Value) Then*
    
  •        cell.Value = 0*
    
  •    End If*
    
  • Next cell*
    End Sub

You can use write cell activity and put 0 on the cell if the blank cell is static or you can uswe condition after looping through datatable like String.IsNullOrEmpty(currentrow(YourColumnName)) then use the write cell there with dynamic cell.

Cheers

1 Like

@Monica_Costa_RPA you dont need VBA. In UiPath studioX do this

  1. Use excel file scope-> select your file.
  2. for each excel row → loop through your table
  3. Inside the loop, if currentRow(“columnName”).ToString.Trim = “”
    Then use set field in excel table → set that column to 0
1 Like

Hello @MontikaChaikittiporn

If there are less column then you can use implement below method

String.IsNullOrWhiteSpace(CurrentRow(“ColumnName”).ToString)

if multiple columns then code :slight_smile:

For Each row As DataRow In dt.Rows
For Each col As DataColumn In dt.Columns
Dim cellValue As String = “”
If Not row.IsNull(col) Then
cellValue = row(col).ToString().Trim()
End If

    If String.IsNullOrEmpty(cellValue) Then
        row(col) = "0"
    End If
Next

Next

Regards,
Rajesh Rane

2 Likes

Thank you for your help. I don’t have set field activity in my UiPath.

@MontikaChaikittiporn Use For Each Excel Row → inside, use Write Cell → set value to
If(String.IsNullOrWhiteSpace(CurrentRow(“ColumnName”).ToString), “0”, CurrentRow(“ColumnName”).ToString)
This writes 0 in blank cells without VBA.