Click Here For FREE VBA MS Access Training!

true 100% comissions


Great MS Excel VBA Books From Amazon:
Click Here To View My List Of MS Excel VBA Books!

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...


That's all, I hope it helped! If not, feel free to email me at erik [at] vbahowto [dot] com

Are you struggling to learn VBA?

If your answer to the above question is yes, then I strongly recommend that you check out these VBA Crash Course videos



Click Here For FREE VBA MS Access Training!

true 100% comissions


Great MS Excel VBA Books From Amazon:
Click Here To View My List Of MS Excel VBA Books!