Home Privacy Policy Feedback Link to us Site Map Forums

Excel: Space Function (VBA only)


In Excel, the Space function returns a string with a specified number of spaces.

The syntax for the Space function is:

Space( number )

number is the number of spaces to be returned.


Applies To:

  • Excel 2007, Excel 2003, Excel XP, Excel 2000

For example:

Space(3) would return "   "
Space(7) would return "       "

VBA Code

The Space function can only be used in VBA code. For example:

Dim LResult As String

LResult = Space(5)

In this example, the variable called LResult would now contain the value "     ".