Skip to main content

T function

Description

T function returns the text referred to by value.

Syntax

T(value)

Parameters

value Required. The value you want to test.

Remarks

  • If value is or refers to text, T returns value. If value does not refer to text, T returns "" (empty text).
  • You do not generally need to use the T function in a formula because Microsoft Excel automatically converts values as necessary. This function is provided for compatibility with other spreadsheet programs.

Examples

Example 1: check for valid numbers

The example may be easier to understand if you copy the example data (include header) in the following table, and paste it in cell A1 of a new Excel worksheet. If you need to, you can adjust the column widths to see all the data.

Data Formula Result Description
Excel =T(A2) Excel Because the value is text, the text is returned.
12/24/2014 =T(A3) Because the value is a data value, empty text is returned.
15:04 =T(A4) Because the value is a time value, empty text is returned.
TRUE =T(A5) Because the value is a logical value, empty text is returned.
FALSE =T(A6) Because the value is a logical value, empty text is returned.
2013 =T(A7) Because the value is a number, empty text is returned.

Example 2: list worksheet names

  1. On the Formulas tab, in the Defined Names group, click Define Name.
  2. In the New Name dialog box, in the Name box, type the name that you want to use for your reference, for this example, type SheetName.
  3. To specify the scope of the name, in the Scope drop-down list box, select Workbook or the name of a worksheet in the workbook. In this example, we select Workbook.
  4. Optionally, in the Comment box, enter a descriptive comment up to 255 characters, in this example we type: Get worksheet names
  5. In the Refers to box, enter the formula:
    =GET.WORKBOOK(1)&T(NOW())

    Get active worksheet name

  6. To finish and return to the worksheet, click OK.
  7. Use the defined Name: in cell A1 or wherever you want the worksheet name to appear, enter the formula:
    =REPLACE(INDEX(SheetName,ROW(A1)),1,FIND("]",INDEX(SheetName,ROW(A1))),)

    or:

    =MID(INDEX(SheetName,ROW(A1)),FIND("]",INDEX(SheetName,ROW(A1)))+1,255)

    Now, you will get the first worksheet name. Dragging down the formula to get all worksheet names.

If you change any worksheet Name, A1 will automatic change the value immediately.

If you want to create a hyperlink to the worksheet, use the following formula:

=HYPERLINK(INDEX(SheetName,ROW(A1))&"!A1",REPLACE(INDEX(SheetName,ROW(A1)),1,FIND("]",INDEX(SheetName,ROW(A1))),))

or

=HYPERLINK(INDEX(SheetName,ROW(A1))&"!A1",MID(INDEX(SheetName,ROW(A1)),FIND("]",INDEX(SheetName,ROW(A1)))+1,255))

Furthermore, you can use CELL function To get active Worksheet name.

Leave a comment

Your email address will not be published. Required fields are marked *

Format your code: <pre><code class="language-vba">place your code here</code></pre>