Convert negative values to value with parentheses

Hi Champs,

I am stuck needed some help Asap, any leads would be appreciated
i have say some negative values say -65767.98, -876456.98, -764764.88 etc.
when pasting to excel i want them in parentheses for ex. : (65767.98),(876456.98) etc.
for this i am using like,
amount = -65767.98
FormatNumber(amount,UseParensForNegativeNumbers:=Tristate.True)
but when checking in mesg box it isgiving value with parentheses but when pasting to excel i cannot see parantheses only the negative values is present , like -65767.98 instead of (65767.98) . can anybody help please.

Thanks !!

hi @Shikhar_Tandon,

Alternative :

UIpath Code

Result in Excel :
image


Mukesh

Hi , Thanks for the reply, but this will add brackets but would not retain the negative value of the number as moving forward i have to do some calculations on this value also.

Thanks
!!

image

How do you want to have the value in excel ? anything from above screenshot


Mukesh

Hi.
You can use ‘replace’.
text=text.replace(“-”,“”)

Should be (123456) when we convert a negative value to a value with parantheses it automatically turns red also .

Thanks

Hi @Shikhar_Tandon,

You can concatenate parentheses to its both end with replacing - with null like this,
"("+Number.ToString.Replace("-","")+")"

hi @Shikhar_Tandon,

I Tried with 3 Samples as shown below

These are the Outputs.

From uipath - You can have anything - It basically depends on the column type you have in Excel .For the above results 2 columns are of type Text as shown below.

image


Mukesh