VBA Concatenate

This is a text and video example of how to join strings together in VBA, (VBA Concatenate):

*************************************************************************************

'IN THIS EXAMPLE I AM ATTACHING SOME TEXT AT 
'THE END OF A TEXT VARIABLE...

Public Sub WriteAreaCode() 

      Dim strText As String 

      strText = Range("A2") 

      strText = Left(strText, 3) 

      Range("B2") = strText & " area code" 

End Sub 

'IN THE FOLLOWING EXAMPLE, I SHOW HOW TO 
'ATTACH 2 TEXT VARIABLES...	

Public Sub WholeName() 

      Dim strFirstName As String 
      Dim strLastName As String 
      Dim strName As String 

'GET THE FIRST AND LAST NAMES... 
      strFirstName = Range("A3") 

      strLastName = Range("B3") 

'CLEAN THE VARIABLES UP.... 
      strFirstName = Trim(strFirstName) 

      strLastName = Trim(strLastName) 

'COMBINE THE 2 VARIABLES... 
      strName = strFirstName & " " & strLastName 

'WRITE THE END RESULT... 
      Range("C3") = strName 

End Sub	

*************************************************************************************

Now watch how it’s done…

Let me know if you have any questions

[simple_contact_form]


Posted

in

by

Tags: