PROVIDING ACCURATE, RELIABLE AND STRAIGHT TO THE POINT KNOWLEDGE ABOUT DIFFERENT IT TOOLS EXPLAINED WITH PRACTICAL EXAMPLES

CONTENTS

HOW TO CONCATENATE TEXT IN VBA

INTRODUCTION

STRINGS is the specific term given to the normal Text in the programming languages.
Strings are very important component in any program as this is the only part of the language through which the program communicate with the user.
We ask the user for the 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”
 
In this article, we will learn how to concatenate or join different text strings in Excel.
 

 

WHAT IS A STRING IN VBA

Simple text is also called as 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.

CONCATENATE THE TEXT GIVEN IN THE CELLS D3 , D4 AND D5

OBJECTIVE

CONCATENATE THE TEXT GIVEN IN THE CELLS D3,D4 AND D5 USING VBA

PLANNING THE SOLUTION

We’ll get the data from the cells and concatenate it. Then again send it to cell D6.
1.Retrieve text present in D3 D4 AND D5.
2.Concatenate the data.
3. Put the data back in D6.

CODE

‘ gyankosh.net
‘ join the text in three given cells and output in fourth cell


Sub jointext()

Dim temp1 As String
Dim temp2 As String
Dim temp3 As String
Dim temp4 As String

temp1 = ActiveSheet.Cells(3, 4).Value ‘ANOTHER WAY OF REACHING A CELL
temp2 = ActiveSheet.Cells(4, 4).Value
temp3 = ActiveSheet.Cells(5, 4).Value

Range(“d6″).Value = temp1 + ” ” + temp2 + ” ” + temp3 ‘CONCATENATING


End Sub

EXPLANATION

We declare temp1, temp2 , temp3 and temp4 as strings for holding the values temporarily.
We retrieve the value with a new method.
Activesheet.cells(row, column).value
All the values are in the temp variables.
we put the value in d6 and concatenate the temp1, temp2 and temp3.

RUNNING THE CODE AND OUTPUT

vba concatenate
VBA CONCATENATING THE TEXT IN DIFFERENT CELLS USING VBA
This was a small article on concatenating the text using vba in Excel.

OTHER WAYS TO REACH THIS ARTICLE

  • WHAT IS EXCEL, HOW EXCEL WORKS, WRITE FORMULA IN EXCEL, EXAMPLE OF USING FORMULA IN EXCEL, ANIMATED EXAMLPE OF USING FORMULA IN EXCEL

LEARN

Encourage us by following at …

If you have any queries or suggestions or any problem which you would like us to solve for you, kindly mail at

[email protected]

Pin It on Pinterest

Share This

KINDLY SPEND FEW SECONDS HERE....

  • PICTURES ARE TOO SMALL?? Don’t worry, Click them, and pinch zoom to see them properly. All pictures are in high resolution.
  • KINDLY LIKE OUR FACEBOOK PAGE BY CLICKING HERE  AND IF WE NEED TO IMPROVE, KINDLY SEND US THE FEEDBACK ON [email protected]
  • Didn’t get what you were looking for?? Just put your question in the chat box present in the Right Lower corner. Name and email id [No spamming, just for the answer of your requirement] are needed.
*CLICK ANYWHERE ELSE TO CLOSE THIS WINDOW
%d bloggers like this: