Using the Excel VBA String Variable - Concatenating, Left, Right, Mid, and Len Functions

preview_player
Показать описание
Grab the Free VBA Quick Reference Guide
You can do a lot with the string variable type. In this video we declare the variable type, use the & to concatenate a string and use the Left, Right, Mid, and Len functions. Master these and you will have mastered Strings in VBA

Code:
===================
Sub Variables()

'==========STRINGS OR CHARACTERS ===============================
Dim s As String
'Default = ""
s = "Strings are for Text"
s = "100" 'Strings can hold numbers and sometimes are smart
'enough to know they are numbers

s = "You concatenate a String "
Debug.Print s
s = s & "by Using the &"
Debug.Print s

'Left the Left number of Characters of a string
sl = Left(s, 3)
Debug.Print sl

'Right the Right Number of Characters of a String
sr = Right(s, 5)
Debug.Print sr

'Mid the Middle Number of Characters of a String from a starting point
sm = Mid(s, 5, 11)
Debug.Print sm

'Len the Length of a string
slen = Len(s)
Debug.Print slen

End Sub
Рекомендации по теме
Комментарии
Автор

Nice video. I have a question do you know the code to match rows any columns.

Dopeboyz