ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Adding parenthesis to a formula? (https://www.excelbanter.com/excel-discussion-misc-queries/210794-adding-parenthesis-formula.html)

Danni2004

Adding parenthesis to a formula?
 
I know that you can toggle the cell references of a formula by highlighting
the set and hitting the F4 button.
A2:B38
$A$2:$B$38
A$2:B$38

But is there a way to highlight a set and place parenthesis around it?
For example,
Go from -- =$A$7/$B$29 to -- =($A$7/$B$29)

Thanks!

Bernard Liengme

Adding parenthesis to a formula?
 
No, you have to use the ( and ) keys
--
Bernard V Liengme
Microsoft Excel MVP
http://people.stfx.ca/bliengme
remove caps from email

"Danni2004" wrote in message
...
I know that you can toggle the cell references of a formula by highlighting
the set and hitting the F4 button.
A2:B38
$A$2:$B$38
A$2:B$38

But is there a way to highlight a set and place parenthesis around it?
For example,
Go from -- =$A$7/$B$29 to -- =($A$7/$B$29)

Thanks!




Dave Peterson

Adding parenthesis to a formula?
 
You could use a macro.

Option Explicit
Sub testme()

Dim myCell As Range
Dim myRng As Range

Set myRng = Nothing
On Error Resume Next
Set myRng = Intersect(Selection, _
Selection.Cells.SpecialCells(xlCellTypeFormulas))
On Error GoTo 0

If myRng Is Nothing Then
MsgBox "Please select some cells with formulas!"
Exit Sub
End If

For Each myCell In myRng.Cells
With myCell
.Formula = "=(" & Mid(.Formula, 2) & ")"
End With
Next myCell
End Sub

If you're new to macros:

Debra Dalgleish has some notes how to implement macros he
http://www.contextures.com/xlvba01.html

David McRitchie has an intro to macros:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

Ron de Bruin's intro to macros:
http://www.rondebruin.nl/code.htm

(General, Regular and Standard modules all describe the same thing.)

Danni2004 wrote:

I know that you can toggle the cell references of a formula by highlighting
the set and hitting the F4 button.
A2:B38
$A$2:$B$38
A$2:B$38

But is there a way to highlight a set and place parenthesis around it?
For example,
Go from -- =$A$7/$B$29 to -- =($A$7/$B$29)

Thanks!


--

Dave Peterson


All times are GMT +1. The time now is 08:52 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com