How to use Space Function in Excel VBA?

Excel VBA provides the Space function that lets you to add spaces with-in your Excel spreadsheet in a intuitive way.

Assume that you need to add 5 spaces between two words Developer and Publish. You would usually do it by entering 5 spaces as shown below

Dim str1 As String

str1 = "Developer" & "     " & "Publish"

MsgBox str1

How to use Space Function in Excel VBA?

The same thing can be achieved using the Space() function in Excel VBA as shown below.

Dim str1 As String

str1 = "Developer" & Space(5) & "Publish"

MsgBox str1

The Space(5) inserts 5 spaces in the specified position.

Leave A Reply

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

You May Also Like

In this post, you’ll learn how to Find Blank cells in excel so that you can remove or delete the blank cells form...
In this article, you’ll learn what is a Gauge Chart in Microsoft Excel. Also, you will learn how to add...
Microsoft Excel provides a shortcut for the users to move columns in excel using two different ways – using Shift...