VBA to read values in parentheses as positve

ThomasOES

Board Regular
Joined
Aug 29, 2017
Messages
174
I need vba code to read values in parentheses as positive

An if statement would be perfect.

Sort of

If (3) Then 3.

Thanks

Tom
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
I need vba code to read values in parentheses as positive

An if statement would be perfect.

Sort of

If (3) Then 3.
That is kind of a general question with no specifics, so the best we can do is give you a general answer that may or may not be the most efficient way to handle your actual data. With that said, try using the Abs function... it returns a positive value whether its argument is positive or negative.
 
Upvote 0
Ok

I've pasted some of the code that leads up to the need for the number in the parentheses to remain as listed in the parentheses.

Selection.End(xlDown).Activate
Set Rng = ActiveCell
Rng.Name = "MonVal"

Sheets(Range("elcell").Value).Activate
Range("S2").Select

ActiveCell.FormulaR1C1 = "=MonVal/R19C28*RC[-5]/(1+R20C28*RC[-17]/R19C28)"
ActiveCell.Copy

As you can see the cell at the bottom of a column of data is named "MonVal"
"MonVal" is used in a formula
I need a previous step to make certain that if "MonVal" has parentheses it is read as listed, not changed to negative. Even taking away the parentheses is okay.

Thanks
Tom
 
Last edited:
Upvote 0
I've pasted some of the code that leads up to the need for the number in the parentheses to remain as listed in the parentheses.

Selection.End(xlDown).Activate
Set Rng = ActiveCell
Rng.Name = "MonVal"

Sheets(Range("elcell").Value).Activate
Range("S2").Select

ActiveCell.FormulaR1C1 = "=ABS(MonVal)/R19C28*RC[-5]/(1+R20C28*RC[-17]/R19C28)"
ActiveCell.Copy

As you can see the cell at the bottom of a column of data is named "MonVal"
"MonVal" is used in a formula
I need a previous step to make certain that if "MonVal" has parentheses it is read as listed, not changed to negative. Even taking away the parentheses is okay.
Try adding what I show in red above
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,849
Members
452,361
Latest member
d3ad3y3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top