English 中文(简体)
Excel: What s the best way to get the value of a Relative Row but from a Fixed Column?
原标题:

The following formula will always return the value of the 4th column (D) of the next row.

=INDIRECT("R[1]C[" & 4-COLUMN() & "]",FALSE)

Is there a better way to achieve the same results?

最佳回答

Similar, but less wordy and easier to read (IMHO), is the A1 style of addressing:

=INDIRECT("$D" & ROW()+1)
问题回答

Putting a $ character in front of a column letter or row number will lock it down when you copy and paste.

Eg:

$C$17

Depends what you mean by better :-)

If you mean shorter/simpler and A1 style, then shoover s answer is fine:

=INDIRECT("$D"&ROW()+1)

If you prefer R1C1 style (easier to read IMHO ;-) ) then an even shorter/simpler/faster solution is:

=INDIRECT("R[1]C4",)

However, if you re after the fastest solution, or just simply prefer a non-volatile one, then a Named Formula is the way to go:

  • Define a Name, say Col4Down1, and set its value to:

    =INDEX(!$D:$D,ROW()+1)

  • Place the following formula in a cell to get the desired result:

    =Col4Down1

This works because of a little known quirk when using the bang operator ! in a Named Formula. When you don t specify a sheetname, !$D:$D always refers to the fourth column irrespective of column deletions/insertions. Think of it as absolute-absolute addressing.

Finally, Lance Roberts answer, whilst being non-volatile, suffers from a couple of problems. As he mentions, it will only work in certain, predetermined, rows. Secondly, insertion/deletion of any columns from A-D, or of any rows above, will break it. Modifying it to fix these leads to the following (if entered into cell B2):

=INDEX(B:B:2:2,ROW()+1,4)

or if you prefer R1C1 style and have set your spreadsheet to use this style:

=INDEX(R:C,ROW()+1,4)

This will work if you know the range:

=INDEX($A$1:$E$4, ROW()+1, 4)




相关问题
import of excel in SQL imports NULL lines

I have a stored procedure that imports differently formatted workbooks into a database table, does work on them then drops the table. Here is the populating query. SELECT IDENTITY(INT,1,1) AS ID ...

Connecting to Oracle 10g with ODBC from Excel VBA

The following code works. the connection opens fine but recordset.recordCount always returns -1 when there is data in the table. ANd If I try to call any methods/properties on recordset it crashes ...

Excel date to Unix timestamp

Does anyone know how to convert an Excel date to a correct Unix timestamp?

C# GemBox Excel Import Error

I am trying to import an excel file into a data table using GemBox and I keep getting this error: Invalid data value when extracting to DataTable at SourceRowIndex: 1, and SourceColumnIndex: 1. As ...

Importing from excel "applications" using SSIS

I am looking for any tips or resources on importing from excel into a SQL database, but specifically when the information is NOT in column and row format. I am currently doing some pre-development ...

热门标签