VBA to read values in parentheses as positve

ThomasOES

Board Regular
Joined
Aug 29, 2017
Messages
116
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
 

Rick Rothstein

MrExcel MVP
Joined
Apr 18, 2011
Messages
35,407
Office Version
2010
Platform
Windows
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.
 

ThomasOES

Board Regular
Joined
Aug 29, 2017
Messages
116
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:

Rick Rothstein

MrExcel MVP
Joined
Apr 18, 2011
Messages
35,407
Office Version
2010
Platform
Windows
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:

Forum statistics

Threads
1,077,855
Messages
5,336,780
Members
399,102
Latest member
chudson1

Some videos you may like

This Week's Hot Topics

Top