Spc function

Category: String / Text

Summary

Returns a string consisting of a specified number of space characters.

Syntax

Spc(n) The required n argument is the number of spaces to insert before displaying or printing the next expression in a list.

Example

Example
This example uses the Spc function to position output in a file and in the Immediate window.
' The Spc function can be used with the Print # statement.
Open "TESTFILE" For Output As #1 ' Open file for output.
Print #1, "10 spaces between here"; Spc(10); "and here."
Close #1 ' Close file.



The following statement causes the text to be printed in the Immediate window (by using the Print method), preceded by 30 spaces.
Debug.Print Spc(30); "Thirty spaces later..."

Microsoft Support Page

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

Back to Functions