View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default 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