試算表函式

本節包括試算表函式的描述,並提供相關範例。

若要使用此指令...

[插入] - [函式] - [類別] [試算表]


[text/scalc/01/func_error_type.xhp#error_type_head not found].

Returns a number representing a specific Error type, or the error value #N/A, if there is no error.

STYLE

Applies a style to the cell containing the formula.

ADDRESS

依據指定的列號和欄號,傳回文字形式的儲存格位址 (參照)。 您可以決定將此位址解譯為絕對位址 (如 $A$1)、相對位址 (如 A1) 還是混合格式 (A$1 或 $A1)。您也可以指定此試算表的名稱。

為了達成互通性,ADDRESS 及 INDIRECT 函式均支援選擇性的參數,該參數可指定是否應使用 R1C1 位址表示法,而非一般的 A1 表示法。

在 ADDRESS 中,此參數作為第四個參數插入,而選擇性的工作表名稱參數則會移到第五個位置。

在 INDIRECT 中,此參數會附加為第二個參數。

在這兩個函式中,若插入的引數值為 0,則使用 R1C1 表示法。若未指定引數或其值非 0,則使用 A1 表示法。

在使用 R1C1 表示法的情況下,ADDRESS 傳回位址字串時使用驚嘆號「!」作為工作表名稱的分隔符,INDIRECT 也需以驚嘆號作為工作表名稱分隔符。在 A1 表示法下,兩個函式仍使用點「.」作為工作表名稱分隔符。

When opening documents from ODF 1.0/1.1 format, the ADDRESS functions that show a sheet name as the fourth parameter will shift that sheet name to become the fifth parameter. A new fourth parameter with the value 1 will be inserted.

儲存 ODF 1.0/1.1 格式的文件時,若 ADDRESS 函式有第四個參數,該參數會遭移除。

note

若 ADDRESS 函式新的第四個參數值為 0,則請勿以舊的 ODF 1.0/1.1 格式儲存試算表。


note

儲存 INDIRECT 函式並不會轉換為 ODF 1.0/1.1 格式。若第二個參數存在,舊版的 Calc 會傳回該函式發生錯誤。


Syntax

ADDRESS(Row; Column [; Abs [; A1 [; "Sheet"]]])

Row 表示儲存格參照的列號

Column 表示儲存格參照的欄號 (數字,而非字母)

Abs 決定參照的類型:

1: absolute ($A$1)

2:列絕對;欄相對 (A$1)

3:列相對;欄絕對 ($A1)

4:相對 (A1)

A1 (選擇性) - 若設為 0,則使用 R1C1 表示法。若此參數不存在或設為非 0 值,則使用 A1 表示法。

Sheet 表示工作表的名稱。必須在前後加上雙引號。

範例

=ADDRESS(1;1;2;;"Sheet2") 傳回下列值:Sheet2.A$1

If the formula above is in cell B2 of current sheet, and the cell A1 in sheet 2 contains the value -6, you can refer indirectly to the referenced cell using a function in B2 by entering =ABS(INDIRECT(B2)). The result is the absolute value of the cell reference specified in B2, which in this case is 6.

AREAS

傳回屬於多個範圍中個別範圍的數字。 範圍可以由相連的儲存格或單一儲存格組成。

函式需要單一引數。若您陳述多個範圍,則必須另以括號將其圍住。可使用分號 (;) 作為分隔輸入多個範圍,但這樣會自動轉換為波浪號 (~) 運算子。波浪號是用來連接範圍。

Syntax

AREAS(reference)

reference 為儲存格或儲存格範圍的參照。

Example

=AREAS((A1:B3;F2;G1)) 當參照 3 個儲存格及/或區域時傳回 3。輸入此項目後即轉換成 =AREAS((A1:B3~F2~G1))。

若已在 [資料] - [定義範圍] 下,定義一個名為 All 的區域,則 =AREAS(All) 會傳回 1。

CHOOSE

使用索引傳回來自清單的值,可多達 30 個值。

Syntax

CHOOSE(Index; Value 1 [; Value 2 [; ... [; Value 30]]])

Index 作為 1 和 30 之間的參照或數字,指定要從清單中取得哪一數值。

Value 1, Value 2, ..., Value 30 is the list of values entered as a reference to a cell or as individual values.

Example

例如,若是 A1 = 2,=CHOOSE(A1;B1;B2;B3;"今天";"明天";"後天") 會傳回儲存格 B2 的內容;若是 A1 = 4,此函式會傳回文字「今天」。

COLUMN

Returns the column number of a cell reference. If the reference is a cell the column number of the cell is returned; if the parameter is a cell area, the corresponding column numbers are returned in a single-row array if the formula is entered as an array formula. If the COLUMN function with an area reference parameter is not used for an array formula, only the column number of the first cell within the area is determined.

Syntax

COLUMN([Reference])

Reference 是指要求解第一欄數的儲存格或儲存格區域參照。

如果未指定參照,則會算出其中輸入公式的儲存格欄編號。LibreOffice Calc 會自動將參照設定在目前儲存格。

Example

=COLUMN(A1) 等於 1。欄 A 是表格中的第一欄。

=COLUMN(C3:E3) 等於 3。欄 C 是表格中的第三欄。

=COLUMN(D3:G10) 傳回 4,因為欄 D 是表格中的第四欄,且 COLUMN 函式未用作陣列公式。(在本例中,一律會以陣列的第一個值作為結果。)

{=COLUMN(B2:B7)}=COLUMN(B2:B7) 皆會傳回 2,因為參照僅包含欄 B 作為表格中的第二欄。由於單欄區域僅有一個欄號,因此公式是否用作陣列公式,並無任何差別。

若在欄 C 中輸入公式,則 =COLUMN() 會傳回 3。

若「兔子」是已命名區域 (C1:D3),則 {=COLUMN(兔子)} 會傳回單列陣列 (3, 4)。

COLUMNS

傳回給定參照中的欄數。

Syntax

COLUMNS(Array)

Array 是將求解總欄數之儲存格範圍的參照。引數也可以是單一儲存格。

Example

=COLUMNS(B5) 傳回 1,因為儲存格僅包含一欄。

=COLUMNS(A1:C5) 等於 3。參照包含三欄。

兔子 是已命名範圍 (C1:D3),則 =COLUMNS(兔子) 會傳回 2。

DDE

傳回 DDE 基礎連結的結果。 如果連結範圍或區段的內容變更,傳回的值也會變更。您必須重新載入試算表或選擇 [編輯] - [連結],以查看已更新的連結。不允許跨平台連結,例如從在 Windows 機器上執行的 LibreOffice 安裝連結至在 Linux 機器上建立的文件。

Syntax

DDE("Server"; "File"; "Range" [; Mode])

Server is the name of a server application. LibreOffice applications have the server name "soffice".

File 是具有路徑的完整檔案名稱。

Range 是含有要評估之資料的區域。

Mode 是選用的參數,它可以控制資料如何從 DDE 伺服器轉換成數字。

Mode

Effect

0 或缺少

「標準」儲存格樣式中的數字格式

1

資料會以美式英文的標準格式來解譯

2

以文字方式套用資料,而不用轉換成數字


Example

=DDE("soffice";"c:\office\document\data1.ods";"sheet1.A1") reads the contents of cell A1 in sheet1 of the LibreOffice Calc spreadsheet data1.ods.

=DDE("soffice";"c:\office\document\motto.odt";"Today's motto") returns a motto in the cell containing this formula. First, you must enter a line in the motto.odt document containing the motto text and define it as the first line of a section named Today's Motto (in LibreOffice Writer under Insert - Section). If the motto is modified (and saved) in the LibreOffice Writer document, the motto is updated in all LibreOffice Calc cells in which this DDE link is defined.

ERRORTYPE

傳回對應至發生在不同儲存格中 錯誤值的數字。利用此數字的協助,您可以產生錯誤訊息文字。

If an error occurs, the function returns a logical or numerical value.

note

如果按一下含有錯誤的儲存格,狀態列會顯示 LibreOffice 中預先定義的錯誤代碼。


Syntax

ERRORTYPE(reference)

Reference 包含儲存格的位址,會於其中報告錯誤。

Example

若儲存格 A1 顯示 Err:518,則函式 =ERRORTYPE(A1) 會傳回數字 518。

Technical information

This function is not part of the Open Document Format for Office Applications (OpenDocument) Version 1.3. Part 4: Recalculated Formula (OpenFormula) Format standard. The name space is

ORG.OPENOFFICE.ERRORTYPE

GETPIVOTDATA

GETPIVOTDATA 函式會從樞紐分析表回傳結果值。該值是使用欄位與項目名稱處理的,因此即使樞紐分析表的版面配置有所改變,數值仍會有效。

Syntax

可以使用兩種不同的語法定義:

GETPIVOTDATA(TargetField; pivot table[; Field 1; Item 1][; ... [Field 126; Item 126]])

or

GETPIVOTDATA(pivot table; Constraints)

第二個語法假設實際提供兩個參數,其中第一個參數為儲存格或儲存格範圍參照。第一個語法假設所有其他情況。[函式精靈] 顯示第一個語法。

First Syntax

TargetField 是用來選取樞紐分析表資料欄位之一的字串。該字串可以是來源欄的名稱,或是如表格內顯示的資料欄位名稱 (像是「Sum - Sales」)。

樞紐分析表 是位於樞紐分析表內,或包含樞紐分析表的儲存格或儲存格範圍參照。如果如果儲存格範圍包含多個樞紐分析表,則會使用最後建立的表格。

如果沒有給予 欄位 n/ 項目 n 的配對,則回傳總計。否則,每一對會加入一個結果必須滿足的限制。欄位 n 是樞紐分析表中的欄位名稱。項目 n 是該欄位中某個項目的名稱。

如果樞紐分析表僅包含單一個滿足所有限制的結果數值,或是個將所有符合數值總結的小計結果,則回傳該結果。如果沒有符合的結果,或是有數個符合結果但它們卻沒有小計,則回傳錯誤。這些條件適用於包含在樞紐分析表中的結果。

如果來源資料包含樞紐分析表設定隱藏的條目,則它們會被忽略。欄位/項目 對的順序並不重要。欄位與項目名稱不區分字母大小寫。

If no constraint for a filter is given, the field's selected value is implicitly used. If a constraint for a filter is given, it must match the field's selected value, or an error is returned. Filters are the fields at the top left of a pivot table, populated using the "Filters" area of the pivot table layout dialog. From each filter, an item (value) can be selected, which means only that item is included in the calculation.

僅在如果樞紐分析表的小計值使用「auto」函式時 (除非在限制中使用,請見下面的 第二個語法) 才能使用。

Second Syntax

樞紐分析表 與第一個語法有相同的意思。

Constraints 是以空格分隔的清單。項目可加上引號 (單引號)。除非從其他儲存格參照字串,否則此字串的前後必須加上引號 (雙引號)。

條目之一可以作為資料欄位名稱。如果樞紐分析表僅包含一項資料欄位,則資料欄位可以略過不填,否則它必須出現。

每個其他的條目以 欄位[項目] 的形式指定限制 (使用 [ 與 ] 字符),或者,僅在如果項目名稱在樞紐分析表其所有的欄位中皆是獨一無二時,才可以直接使用 項目

函式名稱可使用格式 Field[Item;Function] 新增,以使限制僅符合使用該函式的小計值。可能的函式名稱包括 Sum、Count、Average、Max、Min、Product、Count (僅限數字)、StDev (取樣)、StDevP (總體基數)、Var (取樣) 與 VarP (總體基數),不區分大小寫。

HLOOKUP

在選取的區域以下搜尋值與儲存格的參照。 此函式驗證陣列的第一列是否包含特定值。然後此函式傳回同一欄中由 Index 指定的陣列列中的數值。

The search supports wildcards or regular expressions. With regular expressions enabled, you can enter "all.*", for example to find the first location of "all" followed by any characters. If you want to search for a text that is also a regular expression, you must either precede every regular expression metacharacter or operator with a "\" character, or enclose the text into \Q...\E. You can switch the automatic evaluation of wildcards or regular expression on and off in - LibreOffice Calc - Calculate.

warning

When using functions where one or more arguments are search criteria strings that represents a regular expression, the first attempt is to convert the string criteria to numbers. For example, ".0" will convert to 0.0 and so on. If successful, the match will not be a regular expression match but a numeric match. However, when switching to a locale where the decimal separator is not the dot makes the regular expression conversion work. To force the evaluation of the regular expression instead of a numeric expression, use some expression that can not be misread as numeric, such as ".[0]" or ".\0" or "(?i).0".


Syntax

HLOOKUP(Lookup; Array; Index [; SortedRangeLookup])

For an explanation on the parameters, see: VLOOKUP (columns and rows are exchanged)

空白儲存格的處理方式

Example

Suppose we have built a small database table occupying the cell range A1:DO4 and containing basic information about 118 chemical elements. The first column contains the row headings “Element”, “Symbol”, “Atomic Number”, and “Relative Atomic Mass”. Subsequent columns contain the relevant information for each of the elements, ordered left to right by atomic number. For example, cells B1:B4 contain “Hydrogen”, “H”, “1” and “1.008”, while cells DO1:DO4 contain “Oganesson”, “Og”, “118”, and “294”.

A

B

C

D

...

DO

1

Element

Hydrogen

Helium

Lithium

...

Oganesson

2

Symbol

H

He

Li

...

Og

3

Atomic Number

1

2

3

...

118

4

Relative Atomic Mass

1.008

4.0026

6.94

...

294


=HLOOKUP("Lead"; $A$1:$DO$4; 2; 0) returns “Pb”, the symbol for lead.

=HLOOKUP("Gold"; $A$1:$DO$4; 3; 0) returns 79, the atomic number for gold.

=HLOOKUP("Carbon"; $A$1:$DO$4; 4; 0) returns 12.011, the relative atomic mass of carbon.

HYPERLINK

當您按一下包含 HYPERLINK 函式的儲存格,會開啟超連結。

If you use the optional CellValue parameter, the formula locates the URL, and then displays the text or number.

tip

若要使用鍵盤開啟超連結的儲存格,選取儲存格後按下 F2 鍵以進入編輯模式,將游標移至超連結前面並按下 Shift+F10 組合鍵,然後選擇 [開啟超連結]


Syntax

HYPERLINK("URL" [; CellValue])

URL specifies the link target. The optional CellValue parameter is the text or a number that is displayed in the cell and will be returned as the result. If the CellValue parameter is not specified, the URL is displayed in the cell text and will be returned as the result.

為空儲存格和陣列元素傳回數字 0。

Example

=HYPERLINK("http://www.example.org") displays the text "http://www.example.org" in the cell and executes the hyperlink http://www.example.org when clicked.

=HYPERLINK("http://www.example.org";"Click here") displays the text "Click here" in the cell and executes the hyperlink http://www.example.org when clicked.

=HYPERLINK("http://www.example.org";12345) displays the number 12345 and executes the hyperlink http://www.example.org when clicked.

=HYPERLINK($B4) where cell B4 contains http://www.example.org. The function adds http://www.example.org to the URL of the hyperlink cell and returns the same text which is used as formula result.

=HYPERLINK("http://www.";"Click ") & "example.org" displays the text Click example.org in the cell and executes the hyperlink http://www.example.org when clicked.

=HYPERLINK("#Sheet1.A1";"Go to top") displays the text Go to top and jumps to cell Sheet1.A1 in this document.

=HYPERLINK("file:///C:/writer.odt#Specification";"Go to Writer bookmark") displays the text "Go to Writer bookmark", loads the specified text document and jumps to bookmark "Specification".

=HYPERLINK("file:///C:/Documents/";"Open Documents folder") displays the text "Open Documents folder" and shows the folder contents using the standard file manager in your operating system.

INDEX

INDEX returns a reference, a value or an array of values from a reference range, specified by row and column index number or array of row and array of columns index numbers, and an optional range index.

INDEX() returns a reference if the argument is one or more references. When used in a cell in the form =INDEX(), the reference is resolved and the values displayed. When INDEX() is used in arguments of other functions, =FUNCTION(INDEX()...), the function gets the reference passed that was returned by INDEX(). Returning a reference is different from returning an array of values for functions that handles them differently.

Syntax

INDEX(Reference [; [Row] [; [Column] [; Range]]])

Reference is a reference, entered either directly or by specifying a range name. If the reference consists of multiple ranges, you must enclose the list of references or range names in parentheses, or either use the tilde (~) range concatenation operator or define a named range with multiple areas.

Row (optional) represents the row or the array of row indexes of the reference range, for which to return a value. In case of zero or omitted (no specific row) all referenced rows are returned.

Column (optional) represents the column or array of column indexes of the reference range, for which to return a value. In case of zero or omitted (no specific column) all referenced columns are returned.

note

If Row, Column or both are omitted or defined as arrays of indexes, the INDEX function must be entered as an array function.


Range (optional) represents the index of the subrange if referring to a multiple range, default is 1.

Example

{=INDEX({1,3,5;7,9,10},{2;1},1)} return a 2 row array containing 7 and 1. The row index {2;1} pick row 2 then row 1. The columns index 1 picks the first column.

{=INDEX(D3:G12,{1;2;3;4},{3,1})} return a 4 rows by 2 columns array. The row index array {1;2;3;4} picks rows 3 to 6 and {3;1} picks the third (F) and first column (D). Columns 1 and 3 of the source reference are swapped in the resulting array.

=INDEX(Prices;4;1) 從在 [資料] - [定義] 中定義為 [價格] 之資料庫範圍的列 4 欄 1 中傳回值。

=INDEX(SumX;4;1) returns the value from the range SumX in row 4 and column 1 as defined in Sheet - Named Ranges and Expressions - Define.

{=INDEX(A1:B6;1)} returns the values of the first row of A1:B6. Enter the formula as an array formula.

{=INDEX(A1:B6;0;1)} returns the values of the first column of A1:B6. Enter the formula as an array formula.

=INDEX(A1:B6;1;1) 是指 A1:B6 範圍左上方的數值。

{=INDEX((A1:B6;C1:D6);0;0;2)} returns the values of the second range C1:D6 of the multiple range. Enter the formula as an array formula.

INDIRECT

傳回文字字串指定的參照此函式也可用於傳回對應字串的區域。

This function is always recalculated whenever a recalculation occurs.

為了達成互通性,ADDRESS 及 INDIRECT 函式均支援選擇性的參數,該參數可指定是否應使用 R1C1 位址表示法,而非一般的 A1 表示法。

在 ADDRESS 中,此參數作為第四個參數插入,而選擇性的工作表名稱參數則會移到第五個位置。

在 INDIRECT 中,此參數會附加為第二個參數。

在這兩個函式中,若插入的引數值為 0,則使用 R1C1 表示法。若未指定引數或其值非 0,則使用 A1 表示法。

在使用 R1C1 表示法的情況下,ADDRESS 傳回位址字串時使用驚嘆號「!」作為工作表名稱的分隔符,INDIRECT 也需以驚嘆號作為工作表名稱分隔符。在 A1 表示法下,兩個函式仍使用點「.」作為工作表名稱分隔符。

When opening documents from ODF 1.0/1.1 format, the ADDRESS functions that show a sheet name as the fourth parameter will shift that sheet name to become the fifth parameter. A new fourth parameter with the value 1 will be inserted.

儲存 ODF 1.0/1.1 格式的文件時,若 ADDRESS 函式有第四個參數,該參數會遭移除。

note

若 ADDRESS 函式新的第四個參數值為 0,則請勿以舊的 ODF 1.0/1.1 格式儲存試算表。


note

儲存 INDIRECT 函式並不會轉換為 ODF 1.0/1.1 格式。若第二個參數存在,舊版的 Calc 會傳回該函式發生錯誤。


Syntax

INDIRECT(Ref [; A1])

Ref 表示將傳回內容的儲存格或區域 (使用文字格式) 之參照。

A1 (選擇性) - 若設為 0,則使用 R1C1 表示法。若此參數不存在或設為非 0 值,則使用 A1 表示法。

note

If you open an Excel spreadsheet that uses indirect addresses calculated from string functions, the sheet addresses will not be translated automatically. For example, the Excel address in INDIRECT("[filename]sheetname!"&B1) is not converted into the Calc address in INDIRECT("filename#sheetname."&B1).


Example

若 A1 包含 C108 作為參照且儲存格 C108 包含值 100,則 =INDIRECT(A1) 等於 100。

=SUM(INDIRECT("a1:" & ADDRESS(1;3))) 將 A1 區域的儲存格一直加總到由列 1 欄 3 定義之位址的儲存格。亦即區域 A1:C1 的總計。

LOOKUP

Returns the contents of a cell either from a one-row or one-column range. Optionally, the assigned value (of the same index) is returned in a different column and row. As opposed to VLOOKUP and HLOOKUP, search and result vector may be at different positions; they do not have to be adjacent. Additionally, the search vector for the LOOKUP must be sorted ascending, otherwise the search will not return any usable results.

note

若 LOOKUP 找不到搜尋條件,則會於搜尋向量中搜尋小於或等於搜尋條件的最大值。


The search supports wildcards or regular expressions. With regular expressions enabled, you can enter "all.*", for example to find the first location of "all" followed by any characters. If you want to search for a text that is also a regular expression, you must either precede every regular expression metacharacter or operator with a "\" character, or enclose the text into \Q...\E. You can switch the automatic evaluation of wildcards or regular expression on and off in - LibreOffice Calc - Calculate.

warning

When using functions where one or more arguments are search criteria strings that represents a regular expression, the first attempt is to convert the string criteria to numbers. For example, ".0" will convert to 0.0 and so on. If successful, the match will not be a regular expression match but a numeric match. However, when switching to a locale where the decimal separator is not the dot makes the regular expression conversion work. To force the evaluation of the regular expression instead of a numeric expression, use some expression that can not be misread as numeric, such as ".[0]" or ".\0" or "(?i).0".


Syntax

LOOKUP(Lookup; SearchVector [; ResultVector])

Lookup is the value of any type to be looked for; entered either directly or as a reference.

SearchVector 是指要搜尋的單列或單欄區域。

ResultVector 是其他單列或單欄範圍,並會從此範圍取得函式的結果。結果是其索引與搜尋向量中所找到的實例相同之結果向量的儲存格。

空白儲存格的處理方式

Example

=LOOKUP(A1;D1:D100;F1:F100) 會在範圍 D1:D100 的對應儲存格中,搜尋您在 A1 中輸入的數字。並在找到實例時,決定其索引,例如,此範圍中的第 12 個儲存格。然後會傳回第 12 個儲存格的內容,作為函式的值 (於結果向量中)。

MATCH

傳回陣列中符合指定值的項目相關位置。 函式傳回 lookup_array 中找到為數字的值位置。

Syntax

MATCH(Search; LookupArray [; Type])

Search is the value which is to be searched for in the single-row or single-column array.

LookupArray 是搜尋的參照。查找陣列可以是單列或單欄,或者是單列或單欄的一部分。

Type 可以是數值 1、0 或 -1。若 Type = 1 或没有此可選參數,則假定搜尋陣列的第一欄以向上的順序排序。若 Type = -1,則假定該欄以向下的順序排序。這與 Microsoft Excel 中相同的函式相對應。

If Type = 0, only exact matches are found. If the search criterion is found more than once, the function returns the index of the first matching value. Only if Type = 0 can you search for regular expressions (if enabled in calculation options) or wildcards (if enabled in calculation options).

If Type = 1 or the third parameter is missing, the index of the last value that is smaller or equal to the search criterion is returned. For Type = -1, the index of the last value that is larger or equal is returned.

The search supports wildcards or regular expressions. With regular expressions enabled, you can enter "all.*", for example to find the first location of "all" followed by any characters. If you want to search for a text that is also a regular expression, you must either precede every regular expression metacharacter or operator with a "\" character, or enclose the text into \Q...\E. You can switch the automatic evaluation of wildcards or regular expression on and off in - LibreOffice Calc - Calculate.

warning

When using functions where one or more arguments are search criteria strings that represents a regular expression, the first attempt is to convert the string criteria to numbers. For example, ".0" will convert to 0.0 and so on. If successful, the match will not be a regular expression match but a numeric match. However, when switching to a locale where the decimal separator is not the dot makes the regular expression conversion work. To force the evaluation of the regular expression instead of a numeric expression, use some expression that can not be misread as numeric, such as ".[0]" or ".\0" or "(?i).0".


Example

=MATCH(200;D1:D100) 在依欄 D 排序的區域 D1:D100 中搜尋值 200。一旦找到此值,則傳回其所在的列號。若在欄中搜尋時找到更大的值,則傳回前一列的列號。

OFFSET

依指定參照點特定的列與欄數傳回儲存格偏移的值。

This function is always recalculated whenever a recalculation occurs.

Syntax

OFFSET(Reference; Rows; Columns [; Height [; Width]])

Reference 是指函式搜尋新參照的來源參照。

Rows 是指參照向上 (負值) 或向下修正的列數。

Rows 是指參照向上 (負值) 或向下修正的列數。

Height (選擇性) 是以新參照位置開始之區域的上下高度。

Width (選擇性) 是以新參照位置開始之區域的左右寬度。

引數 RowsColumns 不得在列或欄的開頭處出現前置零或為負值。

引數 HeightWidth 不得在列或欄中有前置零或負值的計數。

In the LibreOffice Calc functions, parameters marked as "optional" can be left out only when no parameter follows. For example, in a function with four parameters, where the last two parameters are marked as "optional", you can leave out parameter 4 or parameters 3 and 4, but you cannot leave out parameter 3 alone.

Example

=OFFSET(A1;2;2) 傳回儲存格 C3 (A1 下移兩列兩欄) 中的值。若 C3 包含值 100,則此函式傳回值 100。

=OFFSET(B2:C3;1;1) 傳回下移 1 列並右移 1 欄的 B2:C3 參照 (C3:D4)。

=OFFSET(B2:C3;-1;-1) 傳回上移 1 列並左移 1 欄的 B2:C3 參照 (A1:B2)。

=OFFSET(B2:C3;0;0;3;4) 傳回 B2:C3 的參照,調整大小為 3 列 4 欄 (B2:E4)。

=OFFSET(B2:C3;1;0;3;4) 傳回下移一列並調整大小為 3 列 4 欄的 B2:C3 參照 (B2:E4)。

=SUM(OFFSET(A1;2;2;5;6)) 決定以儲存格 C3 開始並有 5 列高與 6 欄寬的區域總計 (area=C3:H7)。

note

If Width or Height are given, the OFFSET function returns a cell range reference. If Reference is a single cell reference and both Width and Height are omitted, a single cell reference is returned.


ROW

Returns the row number of a cell reference. If the reference is a cell, it returns the row number of the cell. If the reference is a cell range, it returns the corresponding row numbers in a one-column Array if the formula is entered as an array formula. If the ROW function with a range reference is not used in an array formula, only the row number of the first range cell will be returned.

Syntax

ROW([Reference])

Reference 是指儲存格、儲存格區域或區域名稱。

如果未指定參照,則會算出其中輸入公式的儲存格列編號。LibreOffice Calc 會自動將參照置於目前儲存格。

Example

=ROW(B3) 傳回 3,因為參照指向表格中的第三列。

{=ROW(D5:D8)} 傳回單欄陣列 (5、6、7、8),因為指定的參照包含列 5 到 8。

=ROW(D5:D8) 傳回 5,因為 ROW 函式未用作陣列公式,且僅會傳回參照第一列的列號。

{=ROW(A1:E1)}=ROW(A1:E1) 皆傳回 1,因為參照僅包含列 1 作為表格中的第一欄。(由於單列區域僅有一個列號,因此公式是否用作陣列公式,並無任何差別。)

若在列 3 中輸入公式,則 =ROW() 會傳回 3。

若「兔子」是已命名區域 (C1:D3),則 {=ROW(兔子)} 會傳回單欄陣列 (1, 2, 3)。

ROWS

傳回參照或陣列中的列數。

Syntax

ROWS(Array)

Array 是將決定總列數之已命名區域的參照。

Example

=Rows(B5) 傳回 1,因為儲存格僅包含一列。

=ROWS(A10:B12) 傳回 3。

若「兔子」是已命名區域 (C1:D3),則 =ROWS(兔子) 會傳回 3。

SHEET

Returns the sheet number of either a reference or a string representing a sheet name. If you do not enter any parameters, the result is the sheet number of the spreadsheet containing the formula.

Syntax

SHEET([Reference])

Reference 為選用項目,它是儲存格、區域或工作表名稱字串的參照。

Example

=SHEET(Sheet2.A1) returns 2 if Sheet2 is the second sheet in the spreadsheet document.

=SHEET("Sheet3") returns 3 if Sheet3 is the third sheet in the spreadsheet document.

SHEETS

決定參照中的試算表數。 如果您並未輸入任何參數,則會傳回目前文件中的試算表數。

Syntax

SHEETS([Reference])

Reference 是工作表或區域的參照。此參數為選用項目。

Example

若「工作表1」、「工作表2」與「工作表3」依指定的順序存在,則 =SHEETS(Sheet1.A1:Sheet3.G12) 會傳回 3。

VLOOKUP

Vertical search with reference to adjacent cells to the right. This function checks if a specific value is contained in the first column of an array. The function then returns the value in the same row of the column named by Index. If the Sorted parameter is omitted or set to TRUE or one, it is assumed that the data is sorted in ascending order. In this case, if the exact Lookup is not found, the last value that is smaller than the criterion will be returned. If Sorted is set to FALSE or zero, an exact match must be found, otherwise the error Error: Value Not Available will be the result. Thus with a value of zero the data does not need to be sorted in ascending order.

The search supports wildcards or regular expressions. With regular expressions enabled, you can enter "all.*", for example to find the first location of "all" followed by any characters. If you want to search for a text that is also a regular expression, you must either precede every regular expression metacharacter or operator with a "\" character, or enclose the text into \Q...\E. You can switch the automatic evaluation of wildcards or regular expression on and off in - LibreOffice Calc - Calculate.

warning

When using functions where one or more arguments are search criteria strings that represents a regular expression, the first attempt is to convert the string criteria to numbers. For example, ".0" will convert to 0.0 and so on. If successful, the match will not be a regular expression match but a numeric match. However, when switching to a locale where the decimal separator is not the dot makes the regular expression conversion work. To force the evaluation of the regular expression instead of a numeric expression, use some expression that can not be misread as numeric, such as ".[0]" or ".\0" or "(?i).0".


Syntax

=VLOOKUP(Lookup; Array; Index [; SortedRangeLookup])

Lookup is the value of any type looked for in the first column of the array.

Array is the reference, which is to comprise at least as many columns as the number passed in Index argument.

Index 是陣列中的欄號,該陣列包含要傳回的值。第一欄的編號為 1。

SortedRangeLookup is an optional parameter that indicates whether the first column in the array contains range boundaries instead of plain values. In this mode, the lookup returns the value in the row with first column having value equal to or less than Lookup. E.g., it could contain dates when some tax value had been changed, and so the values represent starting dates of a period when a specific tax value was effective. Thus, searching for a date that is absent in the first array column, but falls between some existing boundary dates, would give the lower of them, allowing to find out the data being effective to the searched date. Enter the Boolean value FALSE or zero if the first column is not a range boundary list. When this parameter is TRUE or not given, the first column in the array must be sorted in ascending order. Sorted columns can be searched much faster and the function always returns a value, even if the search value was not matched exactly, if it is greater than the lowest value of the sorted list. In unsorted lists, the search value must be matched exactly. Otherwise the function will return #N/A with message: Error: Value Not Available.

空白儲存格的處理方式

Example

You want to enter the number of a dish on the menu in cell A1, and the name of the dish is to appear as text in the neighboring cell (B1) immediately. The Number to Name assignment is contained in the D1:E100 array. D1 contains 100, E1 contains the name Vegetable Soup, and so forth, for 100 menu items. The numbers in column D are sorted in ascending order; thus, the optional Sorted parameter is not necessary.

請在 B1 中插入下列公式:

=VLOOKUP(A1;D1:E100;2)

只要您在 A1 中輸入編號,則在第二個參照欄 D1:E100 中所屬的文字便會顯示在 B1 中。如果您輸入一個不存在的編號,則文字會以下一個較小的編號顯示。如果不要如此,則請在公式中插入作為最後參數的 FALSE,如此一來,在輸入不存在編號時,便會出現錯誤報告。

Please support us!