Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2
Default adding a formula around a cell reference

I am trying to add a formula in a series of cells that already have a cell
reference.
Example:
(current) =B4
(change to) =round(B4,3)

I have a long series of data that I want to preform a round function on but
do not want to have to do this one by one since there are so many.
Is it possible to add this formula without having to do this procedure one
cell at a time?
  #2   Report Post  
Posted to microsoft.public.excel.misc
dlw dlw is offline
external usenet poster
 
Posts: 510
Default adding a formula around a cell reference

you could use find and replace, but you would still have to enter each cell
reference

"Greek77" wrote:

I am trying to add a formula in a series of cells that already have a cell
reference.
Example:
(current) =B4
(change to) =round(B4,3)

I have a long series of data that I want to preform a round function on but
do not want to have to do this one by one since there are so many.
Is it possible to add this formula without having to do this procedure one
cell at a time?

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default adding a formula around a cell reference

Try this simple macro:

Sub transformer()
' more than meets the eye
For Each r In Selection
s1 = r.Formula
s2 = Right(s1, Len(s1) - 1)
r.Formula = "=ROUND(" & s2 & ",3)"
Next
End Sub

Enter the macro, select the cells, run the macro.
--
Gary''s Student - gsnu200722
  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4,624
Default adding a formula around a cell reference

One way:

Public Sub WrapARound()
Const sWRAPPER As String = "=Round(#, 3)"
Dim rFormulae As Range
Dim rCell As Range
On Error Resume Next 'in case no formulae
Set rFormulae = Selection.Cells.SpecialCells(xlCellTypeFormulas)
On Error GoTo 0
If Not rFormulae Is Nothing Then
For Each rCell In rFormulae
With rCell
If Not .Formula Like "=ROUND(*" Then _
.Formula = Application.Substitute( _
sWRAPPER, "#", Mid(.Formula, 2))
End With
Next rCell
End If
End Sub


In article ,
Greek77 wrote:

I am trying to add a formula in a series of cells that already have a cell
reference.
Example:
(current) =B4
(change to) =round(B4,3)

I have a long series of data that I want to preform a round function on but
do not want to have to do this one by one since there are so many.
Is it possible to add this formula without having to do this procedure one
cell at a time?

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2
Default adding a formula around a cell reference

GREAT! This simple macro saved me hours of tedious work!!
Thanks

"Gary''s Student" wrote:

Try this simple macro:

Sub transformer()
' more than meets the eye
For Each r In Selection
s1 = r.Formula
s2 = Right(s1, Len(s1) - 1)
r.Formula = "=ROUND(" & s2 & ",3)"
Next
End Sub

Enter the macro, select the cells, run the macro.
--
Gary''s Student - gsnu200722

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
adding cell reference on a header Sima Excel Worksheet Functions 4 March 29th 07 07:14 PM
Using a cell reference within a cell reference in a formula david Excel Worksheet Functions 2 July 1st 06 01:05 PM
Adding number to a cell reference not to the contents Go Buckeyes! Excel Worksheet Functions 1 May 28th 06 08:01 PM
What is the shortcut key for adding $ to a cell reference eg $c$3 Bryce Excel Worksheet Functions 2 September 14th 05 02:30 PM
Adding Smart Tags to an unrecognized cell reference SauveC Excel Discussion (Misc queries) 3 February 12th 05 02:01 AM


All times are GMT +1. The time now is 05:57 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"