Join or Concatenate String in VBA

preview_player
Показать описание
In this video we will learn and see
Concatenating string or variable value in VBA.
Getting value from range or cell and concatenating it.
Getting value from user input using Inputbox and concatenating it.
Displaying Double Quotes around text or string.

In VBA we can concatenate/join or text or data using three ways.

& Method
Can join or concatenate any data type (String ,Number)
Data type is implicitly converted into text/string before output no need to first convert non string data in to string.
This is frequently used method for concatenate or join.
Example
1 & 2 will give 12
“1” & “2” will give 12
1 & 2 & “ One” & “ Two” will give 12 One Two

+ Method
Can join only string data type only
Numeric data must be explicitly converted before joining.
Example
1 + 2 will give 3
“1” + “2” will give 12
“1” + “2” + “ One” + “ Two” will give 12 One Two
CStr(1) + CStr(2) + “ One” + “ Two” will give 12 One Two (CStr is VBA function which converts number into string)
1 + 2 + “ One” + “ Two” will give error since 1 and 2 are numbers we need to 1st convert into string (explicit conversion) just like above to have joined or concatenated text.

We can also use worksheet Concat function for joining
Application.WorksheetFunction.Concat(string1,string2,string3)

In all methods string must be enclosed between double quotes (“)
Example
“2” ,”India” etc

====================================================
-Click below link to subscribe channel and stay tuned with latest uploads.
-Channel link
If liked this video then please subscribe,like and don't forget to click bell icon.
Make comment about your views, any suggestion or video topic you like to see.
======================================
🌐 Websites 🌐
=====================================================
You can watch and learn from below videos also


Auto highlight Active cell VBA.





Рекомендации по теме