0

I would like to replace the value of a cell with the result of a formula which refers to the cell itself. I tried to allow circular reference (1 cycle) but it didn't help.

Say I have a number in cell A1 (and cells below), I would like to replace its content with the following formula: =A1/60 (the same for the rest of the column).

Of course I can do that with a new column on the side, but I would like to achieve this without inserting a new column. Or maybe create some automation that adds a new one far away, do stuff and then removes it.

Community
  • 1
  • 1
Jordan
  • 594
  • 1
  • 6
  • 14
  • use a Macro which taking cells as parameter ! – angel Jun 13 '14 at 11:56
  • possible duplicate of [Using a UDF in Excel to update the worksheet](http://stackoverflow.com/questions/23433096/using-a-udf-in-excel-to-update-the-worksheet) –  Jun 13 '14 at 11:57
  • Have a look at [**this**](http://stackoverflow.com/questions/6335563/self-reference-for-cell-column-and-row-in-worksheet-functions) SO question, it may help – Alex Gidan Jun 13 '14 at 11:58

2 Answers2

3
  • Enter 60 in a cell somewhere and copy it.
  • Select ColumnA ..... FILE .... Clipboard ..... Paste - Paste Special
  • Then check Divide, press OK
brettdj
  • 54,857
  • 16
  • 114
  • 177
pnuts
  • 58,317
  • 11
  • 87
  • 139
  • who knows, it's likely to be a peril of editing/commenting elsewhere. Its the best answer here. – brettdj Sep 19 '15 at 05:58
1

Select the cells you want to change and run this small macro:

Sub FormulaMaker()
    Dim V As Variant
    Dim r As Range
    For Each r In Selection
        V = r.Value
        If V = "" Then V = 0
        r.Formula = "=" & V & "/60"
    Next r
End Sub

Macros are very easy to install and use:

  1. ALT-F11 brings up the VBE window
  2. ALT-I ALT-M opens a fresh module
  3. paste the stuff in and close the VBE window

If you save the workbook, the macro will be saved with it. If you are using a version of Excel later then 2003, you must save the file as .xlsm rather than .xlsx

To remove the macro:

  1. bring up the VBE window as above
  2. clear the code out
  3. close the VBE window

To use the macro from Excel:

  1. ALT-F8
  2. Select the macro
  3. Touch RUN

To learn more about macros in general, see:

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

and

http://msdn.microsoft.com/en-us/library/ee814735(v=office.14).aspx

Macros must be enabled for this to work!

Gary's Student
  • 95,722
  • 10
  • 59
  • 99