Fix 'minus symbols' after a number in a datatable - Excel Automation

Hi Folks,

I have a datatable with below sample data.

image

Need to fix the highlighted cell values as the minus symbol is coming after the number, it should be before the number.

How can do this in the datatable and check for every column.

Thanks in advance :slight_smile:

Hi @shikharno.7

Try this by using Invoke Code activity

Code:

Dim dataTable As DataTable = DT ' Replace with your DataTable variable name

For Each column As DataColumn In dataTable.Columns
    For Each row As DataRow In dataTable.Rows
        Dim cellValue As String = row(column).ToString()
        If cellValue.EndsWith("-") Then
            ' Reformat the cell value with the minus symbol before the number
            row(column) = "-" & cellValue.TrimEnd("-"c)
        End If
    Next
Next

BlankProcess12.zip (57.4 KB)

I/P:
image

O/P:
image

Hope this helps!!

1 Like

@shikharno.7

use find/replace activity

cheers

1 Like

Maybe you are interested on a general harmonization:
grafik

Alternate: Regex

1 Like

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