Adding parenthesis to a formula?

  • Thread starter Thread starter Danni2004
  • Start date Start date
D

Danni2004

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!
 
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 here:
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.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

parenthesis 1
Excel 2002: How to look up for the last entry ? 5
Help for the formula 9
Auto Insert Parenthesis 3
macro search 15
adding =if(iserror to formula 6
sum 2
Multiple colums into a single cell 8

Back
Top