Space VBA function – How to create multiple spaces

1. Space VBA function – Description

The Space VBA function returns the number of spaces specified in the argument. So, if we want to get a text with only 100 spaces, enter the number 100 in the argument.

2. VBA Space function – Syntax

Space (integer)

Integer  – The number of spaces we want to return with the function.

Function return : String / text value.

3. VBA Space function – Example

How to use the Space  function  in VBA Excel? Below is an example of using the Space  function  in the VisualBasic Editor.

Sub SpaceFunctionExample ()

MsgBox Space (10)
MsgBox "text" & Space (20) & "text"
Range ("A1") = "text" & Space (20) & "text"
MsgBox Range ("A1") & Space (10) & "text"

End Sub
Excel VBA functions - Space VBA function
Excel VBA functions – Space VBA function

4. Space VisualBasic function – Where to use?

The function can be used in: Excel 2003, Excel 2007, Excel 2010, Excel 2013, Excel 2016.

The article is part of the VBA Excel function list. You can find a list of all VBA functions at this address:  VBA functions.

Leave a comment

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

%d bloggers like this: