Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
rcc rcc is offline
external usenet poster
 
Posts: 21
Default adding the same formula to several cells without changing cell lin

Hi,

I have a column of cells that are linked to several different worksheets.
I'd like the number in each cell to be rounded to the nearest 100, but I
don't want to enter =round(##,-3) for every single cell, and I can't just
enter it for one and drag because that would change my links. Is there a way
to round a column of numbers without dragging and without entering the
formula in for each cell?

Thanks,
RCC
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4,393
Default adding the same formula to several cells without changing cell lin

1) Might be possible with some VBA code to take the existing formula and
wrap it in the ROUND. If interested post to the Excel programming newsgroup
asking for this.
2) As a first attempt I would be tempted to add a new column to the right of
the existing one (lets say it is B) and add =ROUND(B2,-2) Then hide column
B. Note it is -2 to round to 100 (a typo, I expect)
best wishes
--
Bernard V Liengme
Microsoft Excel MVP
www.stfx.ca/people/bliengme
remove caps from email

"rcc" wrote in message
...
Hi,

I have a column of cells that are linked to several different worksheets.
I'd like the number in each cell to be rounded to the nearest 100, but I
don't want to enter =round(##,-3) for every single cell, and I can't just
enter it for one and drag because that would change my links. Is there a
way
to round a column of numbers without dragging and without entering the
formula in for each cell?

Thanks,
RCC



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,440
Default adding the same formula to several cells without changing cell lin

You might consider using

ToolsOptionsCalculation tab, and check Precision as displayed.

Do read HELP first so you understand the implications.

--
Kind regards,

Niek Otten
Microsoft MVP - Excel

"rcc" wrote in message ...
| Hi,
|
| I have a column of cells that are linked to several different worksheets.
| I'd like the number in each cell to be rounded to the nearest 100, but I
| don't want to enter =round(##,-3) for every single cell, and I can't just
| enter it for one and drag because that would change my links. Is there a way
| to round a column of numbers without dragging and without entering the
| formula in for each cell?
|
| Thanks,
| RCC


  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4,393
Default adding the same formula to several cells without changing cell lin

This will do it. Copy this subroutine to a general module. Select the cells
to change (remember you can select non-contiguous cell using CTRL); then run
the subroutine (Tools | Macro | Rum Macro)
Need help with VBA? See David McRitchie's site on "getting started" with VBA
http://www.mvps.org/dmcritchie/excel/getstarted.htm

Sub wrapper()
For Each mycell In Selection
holdFormula = mycell.Formula
holdFormula = Mid(holdFormula, 2)
newFormula = "=ROUND(" & holdFormula & ",-2)"
mycell.Formula = newFormula
Next
End Sub

best wishes
--
Bernard V Liengme
Microsoft Excel MVP
www.stfx.ca/people/bliengme
remove caps from email

"rcc" wrote in message
...
Hi,

I have a column of cells that are linked to several different worksheets.
I'd like the number in each cell to be rounded to the nearest 100, but I
don't want to enter =round(##,-3) for every single cell, and I can't just
enter it for one and drag because that would change my links. Is there a
way
to round a column of numbers without dragging and without entering the
formula in for each cell?

Thanks,
RCC



  #5   Report Post  
Posted to microsoft.public.excel.misc
rcc rcc is offline
external usenet poster
 
Posts: 21
Default adding the same formula to several cells without changing cell

Thanks, Bernard.

"Bernard Liengme" wrote:

This will do it. Copy this subroutine to a general module. Select the cells
to change (remember you can select non-contiguous cell using CTRL); then run
the subroutine (Tools | Macro | Rum Macro)
Need help with VBA? See David McRitchie's site on "getting started" with VBA
http://www.mvps.org/dmcritchie/excel/getstarted.htm

Sub wrapper()
For Each mycell In Selection
holdFormula = mycell.Formula
holdFormula = Mid(holdFormula, 2)
newFormula = "=ROUND(" & holdFormula & ",-2)"
mycell.Formula = newFormula
Next
End Sub

best wishes
--
Bernard V Liengme
Microsoft Excel MVP
www.stfx.ca/people/bliengme
remove caps from email

"rcc" wrote in message
...
Hi,

I have a column of cells that are linked to several different worksheets.
I'd like the number in each cell to be rounded to the nearest 100, but I
don't want to enter =round(##,-3) for every single cell, and I can't just
enter it for one and drag because that would change my links. Is there a
way
to round a column of numbers without dragging and without entering the
formula in for each cell?

Thanks,
RCC






  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default adding the same formula to several cells without changing cell lin

Sub RoundAdd()
Dim myStr As String
Dim cel As Range
For Each cel In Selection
If cel.HasFormula = True Then
If Not cel.Formula Like "=ROUND(*" Then
myStr = Right(cel.Formula, Len(cel.Formula) - 1)
cel.Value = "=ROUND(" & myStr & ",-3)"
End If
End If
Next
End Sub

If you're not familiar with VBA and macros, see David McRitchie's site for
more on "getting started".

http://www.mvps.org/dmcritchie/excel/getstarted.htm

In the meantime..........

First...create a backup copy of your original workbook.

To create a General Module, hit ALT + F11 to open the Visual Basic Editor.

Hit CRTL + r to open Project Explorer.

Find your workbook/project and select it.

Right-click and InsertModule. Paste the code in there. Save the
workbook and hit ALT + Q to return to your workbook.

Run or edit the macro by going to ToolMacroMacros.

You can also assign this macro to a button or a shortcut key combo.


Gord Dibben MS Excel MVP

On Wed, 17 Oct 2007 11:34:01 -0700, rcc wrote:

Hi,

I have a column of cells that are linked to several different worksheets.
I'd like the number in each cell to be rounded to the nearest 100, but I
don't want to enter =round(##,-3) for every single cell, and I can't just
enter it for one and drag because that would change my links. Is there a way
to round a column of numbers without dragging and without entering the
formula in for each cell?

Thanks,
RCC


  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default adding the same formula to several cells without changing cell lin

Change -3 to -2 as Bernard pointed out.

Gord

On Wed, 17 Oct 2007 12:04:53 -0700, Gord Dibben <gorddibbATshawDOTca wrote:

Sub RoundAdd()
Dim myStr As String
Dim cel As Range
For Each cel In Selection
If cel.HasFormula = True Then
If Not cel.Formula Like "=ROUND(*" Then
myStr = Right(cel.Formula, Len(cel.Formula) - 1)
cel.Value = "=ROUND(" & myStr & ",-3)"
End If
End If
Next
End Sub

If you're not familiar with VBA and macros, see David McRitchie's site for
more on "getting started".

http://www.mvps.org/dmcritchie/excel/getstarted.htm

In the meantime..........

First...create a backup copy of your original workbook.

To create a General Module, hit ALT + F11 to open the Visual Basic Editor.

Hit CRTL + r to open Project Explorer.

Find your workbook/project and select it.

Right-click and InsertModule. Paste the code in there. Save the
workbook and hit ALT + Q to return to your workbook.

Run or edit the macro by going to ToolMacroMacros.

You can also assign this macro to a button or a shortcut key combo.


Gord Dibben MS Excel MVP

On Wed, 17 Oct 2007 11:34:01 -0700, rcc wrote:

Hi,

I have a column of cells that are linked to several different worksheets.
I'd like the number in each cell to be rounded to the nearest 100, but I
don't want to enter =round(##,-3) for every single cell, and I can't just
enter it for one and drag because that would change my links. Is there a way
to round a column of numbers without dragging and without entering the
formula in for each cell?

Thanks,
RCC


  #8   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default adding the same formula to several cells without changing cell lin

Just don't run it on any cells that don't have a formula or any that already
have ROUND function.


Gord

On Wed, 17 Oct 2007 15:56:47 -0300, "Bernard Liengme"
wrote:

This will do it. Copy this subroutine to a general module. Select the cells
to change (remember you can select non-contiguous cell using CTRL); then run
the subroutine (Tools | Macro | Rum Macro)
Need help with VBA? See David McRitchie's site on "getting started" with VBA
http://www.mvps.org/dmcritchie/excel/getstarted.htm

Sub wrapper()
For Each mycell In Selection
holdFormula = mycell.Formula
holdFormula = Mid(holdFormula, 2)
newFormula = "=ROUND(" & holdFormula & ",-2)"
mycell.Formula = newFormula
Next
End Sub

best wishes


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 up various columns based on the value of one changing cell Darrilyn Excel Worksheet Functions 4 September 6th 07 06:56 PM
Changing the color of cells by formula Emerogork Excel Worksheet Functions 1 August 24th 07 12:32 AM
changing a formula in multiple cells casdaq Excel Worksheet Functions 2 April 30th 07 11:54 PM
adding cells within a cell DC Charts and Charting in Excel 1 September 20th 06 06:04 PM
My formula cell has stopped adding the preceding cells. Miriam Excel Worksheet Functions 1 June 2nd 06 03:35 PM


All times are GMT +1. The time now is 04:47 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"