HOW TO INSERT STRINGS IN EXCEL USING VBA

Table of Contents

INTRODUCTION

STRINGS is the specific term given to the normal Text in the programming languages.

Strings are a very important component in any program as this is the only part of the language through which the program communicates with the user.

We ask the user for input through a STRING.

We process the user input. We return the output to the user through a STRING.

So we can understand the importance of Strings in VBA.

Many times we need to handle strings very carefully for which we need to know several types of manipulations so that we can make our application can communicate effectively.


” STRINGS ARE THE ONLY WAY THROUGH WHICH OUR APPLICATIONS COMMUNICATE WITH THE USER”

So, we’ll learn many types of STRING MANIPULATIONS in this article.

WHAT IS A STRING IN VBA

Simple text is a String.

String is a collection of characters.

As we know programming languages considers the characters as the basic unit.

So when characters combine STRINGS are formed.e.g.”WELCOME TO GYANKOSH.NET” is a String.

INSERTING THE STRING / TEXT INTO CELL

OBJECTIVE

ENTER THE TEXT “WELCOME TO GYANKOSH.NET” INTO THE CELL D3 USING VBA.

Make use of VBA to enter the given text into cell positioned at location D3.

PLANNING THE SOLUTION

In this case we simply need to send the String to the cell.

Steps:

1. Select the cell.

2. Put the string into the cell.

CODE

' gyankosh.net

' putting a custom text/string in a specified cell

Sub stringtocell()

Range("d3").Value = "WELCOME TO GYANKOSH.NET"

End Sub

EXPLANATION

There is just one statement in the code.

Range(“d3”) refers to CELL D3.VALUE refers to the value of D3.

So we put the value of D3 as String “WELCOME TO GYANKOSH.NET”

RUNNING THE CODE AND OUTPUT

VBA -PUTTING A TEXT IN A CELL