Tab function

Category: Program Flow / Interaction

Summary

Used with Print statements to position output at a specific column number.

Syntax

Tab[ (n) ] The optional n argument is the column number moved to before displaying or printing the next expression in a list. If omitted, Tab moves the insertion point to the beginning of the next print zone. This allows Tab to be used instead of a comma in locales where the comma is used as a decimal separator.

Example

Example
This example uses the Tab function to position output in a file and in the Immediate window.
' The Tab function can be used with the Print # statement.
Open "TESTFILE" For Output As #1 ' Open file for output.
' The second word prints at column 20.
Print #1, "Hello"; Tab(20); "World."
' If the argument is omitted, cursor is moved to the next print zone.
Print #1, "Hello"; Tab; "World"
Close #1 ' Close file.



The Tab function can also be used with the Print method. The following statement prints text starting at column 10.
Debug.Print Tab(10); "10 columns from start."

Microsoft Support Page

https://learn.microsoft.com/en-us/office/vba/language/reference/user-interface-help/tab-function

Back to Functions