Absolute referencing - Inserting the equivalent of '$' in an equation written in R1C1 notation

前端 未结 1 360
余生分开走
余生分开走 2021-01-21 00:01

I have this equation that I am using VBA to enter into a cell on my spreadsheet:

ActiveCell.FormulaR1C1 = \"=VLOOKUP(RC[-3],RC[-1]:R[\" & CellNumber & \"         


        
1条回答
  •  不知归路
    2021-01-21 00:55

    If not yet maybe one day you may notice the difference is that absolute references (i) do not use square brackets and (ii) always have a number immediately to the right of R and C, eg R1C1, which means Row 1, Column1 – usually expressed A1 (though sometimes R1C1 in the spreadsheet itself, as well as in a macro - when in what is termed R1C1 reference style).

    RC[-3] is a relative reference and means whatever row happens to be the current one (no value immediately to the right of R, so no offset from the current row) and three columns to the left (because negative) of whatever happens to be the current column.

    So if in D1, RC[-3] references exactly the same location as R1C1 does – ie what is generally known as A1.

    However because a relative reference, put RC[-3] in E1 and it will reference B1, whereas R1C1 (as does $A$1) refers to A1 wherever it is placed.

    Now, your example mentions Active Cell - that is where you formula will be placed and is the start point for "in the same row but three columns to the left". But you have not shown how the active cell was selected so we can't tell which cell to start from, therefore the location (rather than the direction/distance away) where you want to end up.

    If on a chessboard for example, relative references might be "move your knight two rows up and one column to the right" whereas absolute would be "put your knight in square King 4".

    In a sense, both 'systems' are relative – just that the "absolute" one is always relative to the top left-hand corner (except when using RTL layout).

    It might help to think of the square brackets together [ ] as "from the cell I am in".

    The equivalent of 'negative columns means to the left' for rows is 'up'.

    0 讨论(0)
提交回复
热议问题