Cell references absolute or relative

%3CLINGO-SUB%20id%3D%22lingo-sub-1888841%22%20slang%3D%22en-US%22%3ECell%20references%20absolute%20or%20relative%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1888841%22%20slang%3D%22en-US%22%3E%3CP%20class%3D%22p1%22%3E%3CSPAN%20class%3D%22s1%22%3EFor%20single%20Cells%2C%20Excel%20offers%20two%20relevant%20methods%20of%20Copying%20to%20other%20locations.%3C%2FSPAN%3E%3C%2FP%3E%3CP%20class%3D%22p1%22%3E%3CSPAN%20class%3D%22s1%22%3EThe%20default%20Copy%20and%20Paste%20commands%20give%20the%20target%20cell%20the%20same%20formula%2C%20with%20Cell%20references%20adjusted.%20This%20is%20not%20a%20pure%20Copy.%3C%2FSPAN%3E%3C%2FP%3E%3CP%20class%3D%22p1%22%3E%3CSPAN%20class%3D%22s1%22%3EThe%20other%20choice%20is%20to%20Copy%20not%20the%20entire%20Cell%20but%20only%20the%20formula%20it%20contains%2C%20in%20which%20case%20Paste%20will%20give%20the%20target%20Cell%20unadjusted%20references.%20This%20is%20a%20pure%20Copy.%3C%2FSPAN%3E%3C%2FP%3E%3CP%20class%3D%22p1%22%3E%3CSPAN%20class%3D%22s1%22%3E(Quite%20separately%2C%20how%20should%20we%20distinguish%20between%20an%20entire%20Cell%20and%20the%20formula%20it%20contains%3F)%3C%2FSPAN%3E%3C%2FP%3E%3CP%20class%3D%22p1%22%3E%3CSPAN%20class%3D%22s1%22%3EMy%20interest%20is%20in%20Ranges%2C%20not%20individual%20Cells.%3C%2FSPAN%3E%3C%2FP%3E%3CP%20class%3D%22p1%22%3E%3CSPAN%20class%3D%22s1%22%3EMy%20experience%2C%20since%20about%20Excel%204%20in%20about%201990%2C%20is%20that%20with%20a%20Range%2C%20the%20only%20choice%20is%20to%20use%20the%20default%20Copy%20and%20Paste%20commands%2C%20giving%20the%20same%20formula%2C%20with%20Cell%20references%20adjusted%2C%20which%20means%20two%20or%20more%20Cells%20must%20be%20dealt%20with%20manually%20and%20individually.%3C%2FSPAN%3E%3C%2FP%3E%3CP%20class%3D%22p1%22%3E%3CSPAN%20class%3D%22s1%22%3EI%20seek%20a%20means%20of%20Copying%20%E2%80%9Conly%20the%20formulae%E2%80%9D%20for%20a%20Range%2C%20to%20give%20the%20target%20cell%20the%20same%20formula%2C%20with%20Cell%20references%20unadjusted.%3CBR%20%2F%3EAround%20the%20time%20of%20Excel%204%2C%20non-MS%20spreadsheet%20rival%20SuperCalc%20found%20this%20%E2%80%9Cproblem%E2%80%9D%20trivial%2C%20which%20suggests%20MS%20ought%20to%2C%20also.%26nbsp%3BTwo%20generations%20ago%20SuperCalc%20didn%E2%80%99t%20care%20whether%20the%20source%20was%20a%20single%20Cell%20or%20a%20Range%E2%80%A6%20it%20always%20offered%20the%20choice%20of%20Copying%20or%20Replicating%2C%20one%20giving%20pure%20and%20the%20other%20relative%20offset%20Cell%20references.%20(Quite%20separately%2C%20SuperCalc%20shot%20itself%20in%20the%20foot%20with%20v4%20and%20went%20on%20to%20chop%20off%20its%20own%20shins%2C%20knees%2C%20thighs%2C%20pelvis%20and%20torso%20with%20v5.%20That%E2%80%99s%20wholly%20beside%20the%20point.)%3C%2FSPAN%3E%3C%2FP%3E%3CP%20class%3D%22p1%22%3E%3CSPAN%20class%3D%22s1%22%3E(%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fexcel%2Fcopy-and-paste-a-range-of-cells-and-keep-formula-eferences%2Fm-p%2F478853%22%20target%3D%22_blank%22%3E%3CSPAN%20class%3D%22s2%22%3Ehttps%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fexcel%2Fcopy-and-paste-a-range-of-cells-and-keep-formula-eferences%2Fm-p%2F478853%3C%2FSPAN%3E%3C%2FA%3E)%20is%20the%20closest%20useful%20reference%20I%20could%20find%20here%2C%20where%26nbsp%3BSergei%20Baklan%20suggested%20a%20workaround%20to%20a%20similar%20problem%3A%3C%2FSPAN%3E%3C%2FP%3E%3CP%20class%3D%22p1%22%3E%3CSPAN%20class%3D%22s1%22%3E-%20select%20entire%20Range%3C%2FSPAN%3E%3C%2FP%3E%3CP%20class%3D%22p1%22%3E%3CSPAN%20class%3D%22s1%22%3E-%20Ctrl%2BH%20and%20replace%20%3D%20on%20%23%3C%2FSPAN%3E%3C%2FP%3E%3CP%20class%3D%22p1%22%3E%3CSPAN%20class%3D%22s1%22%3E-%20Copy%2FPaste%20the%20range%20on%20new%20location%3C%2FSPAN%3E%3C%2FP%3E%3CP%20class%3D%22p1%22%3E%3CSPAN%20class%3D%22s1%22%3E-%20select%20Range%2C%20Ctrl%2BH%20and%20replace%20%23%20on%20%3D%20(for%20both%20Ranges)%3C%2FSPAN%3E%3C%2FP%3E%3CP%20class%3D%22p1%22%3E%3CSPAN%20class%3D%22s1%22%3EAm%20I%20missing%20something%2C%20or%20is%20%26nbsp%3BSergei%E2%80%99s%20suggestion%20really%20the%20least%20clunky%20solution%20MS%20can%20offer%3F%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1888841%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1888941%22%20slang%3D%22en-US%22%3ERe%3A%20Cell%20references%20absolute%20or%20relative%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1888941%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F798092%22%20target%3D%22_blank%22%3E%40Robbie_Goodwin%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20you%20can't%20make%20the%20cell%20references%20absolute%20(%24A%242%20instead%20if%20A2)%2C%20Sergei's%20tip%20is%20the%20best%20you%20can%20do%20without%20VBA.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20might%20use%20the%20following%20macro.%20If%20you%20store%20it%20in%20a%20module%20in%20your%20personal%20macro%20workbook%20Personal.xlsb%2C%20it%20will%20be%20available%20in%20all%20workbooks%2C%20and%20you%20can%20assign%20it%20to%20(for%20example)%20a%20Quick%20Access%20Toolbar%20button.%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-visual%22%3E%3CCODE%3ESub%20CopyFormulas()%0A%20%20%20%20Dim%20rngSource%20As%20Range%0A%20%20%20%20Dim%20rngTarget%20As%20Range%0A%20%20%20%20On%20Error%20Resume%20Next%0A%20%20%20%20Set%20rngSource%20%3D%20Application.InputBox(Prompt%3A%3D%22Select%20the%20source%20range%22%2C%20_%0A%20%20%20%20%20%20%20%20Default%3A%3DSelection.Address%2C%20Type%3A%3D8)%0A%20%20%20%20If%20rngSource%20Is%20Nothing%20Then%0A%20%20%20%20%20%20%20%20Beep%0A%20%20%20%20%20%20%20%20Exit%20Sub%0A%20%20%20%20End%20If%0A%20%20%20%20Set%20rngTarget%20%3D%20Application.InputBox(Prompt%3A%3D%22Select%20the%20target%20range%22%2C%20_%0A%20%20%20%20%20%20%20%20Type%3A%3D8)%0A%20%20%20%20If%20rngTarget%20Is%20Nothing%20Then%0A%20%20%20%20%20%20%20%20Beep%0A%20%20%20%20%20%20%20%20Exit%20Sub%0A%20%20%20%20End%20If%0A%20%20%20%20rngTarget.Formula%20%3D%20rngSource.Formula%0AEnd%20Sub%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E
Occasional Visitor

For single Cells, Excel offers two relevant methods of Copying to other locations.

The default Copy and Paste commands give the target cell the same formula, with Cell references adjusted. This is not a pure Copy.

The other choice is to Copy not the entire Cell but only the formula it contains, in which case Paste will give the target Cell unadjusted references. This is a pure Copy.

(Quite separately, how should we distinguish between an entire Cell and the formula it contains?)

My interest is in Ranges, not individual Cells.

My experience, since about Excel 4 in about 1990, is that with a Range, the only choice is to use the default Copy and Paste commands, giving the same formula, with Cell references adjusted, which means two or more Cells must be dealt with manually and individually.

I seek a means of Copying “only the formulae” for a Range, to give the target cell the same formula, with Cell references unadjusted.
Around the time of Excel 4, non-MS spreadsheet rival SuperCalc found this “problem” trivial, which suggests MS ought to, also. Two generations ago SuperCalc didn’t care whether the source was a single Cell or a Range… it always offered the choice of Copying or Replicating, one giving pure and the other relative offset Cell references. (Quite separately, SuperCalc shot itself in the foot with v4 and went on to chop off its own shins, knees, thighs, pelvis and torso with v5. That’s wholly beside the point.)

(https://techcommunity.microsoft.com/t5/excel/copy-and-paste-a-range-of-cells-and-keep-formula-eferen...) is the closest useful reference I could find here, where Sergei Baklan suggested a workaround to a similar problem:

- select entire Range

- Ctrl+H and replace = on #

- Copy/Paste the range on new location

- select Range, Ctrl+H and replace # on = (for both Ranges)

Am I missing something, or is  Sergei’s suggestion really the least clunky solution MS can offer?

2 Replies

@Robbie_Goodwin 

If you can't make the cell references absolute ($A$2 instead if A2), Sergei's tip is the best you can do without VBA.

 

You might use the following macro. If you store it in a module in your personal macro workbook Personal.xlsb, it will be available in all workbooks, and you can assign it to (for example) a Quick Access Toolbar button.

Sub CopyFormulas()
    Dim rngSource As Range
    Dim rngTarget As Range
    On Error Resume Next
    Set rngSource = Application.InputBox(Prompt:="Select the source range", _
        Default:=Selection.Address, Type:=8)
    If rngSource Is Nothing Then
        Beep
        Exit Sub
    End If
    Set rngTarget = Application.InputBox(Prompt:="Select the target range", _
        Type:=8)
    If rngTarget Is Nothing Then
        Beep
        Exit Sub
    End If
    rngTarget.Formula = rngSource.Formula
End Sub

@Robbie_Goodwin 

My solution would be to lease Microsoft 365 and consign the concept of relative referencing to the trash can of history

 

Neither the processing of arrays nor lists in Tables in 365 requires the concept of relative referencing, provided you apply a Name to the Range.  On the occasions when terms within the formula do need to be evaluated individually the '@' operator is usually sufficient.