This is a text and video example of how to write a VBA Trim function:
*************************************************************************************
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
Public Sub GetLastName() Dim strLastName As String strLastName = Range("A2") strLastName = Right(strLastName, 8) 'THE TRIM FUNCTION CLEANS THE VBA STRING VARIABLE OF 'ANY LINGERING SPACES BOTH BEFORE AND AFTER... 'IT MAKES " Jack" (WITH A SPACE IN THE BEGINNING) ' LOOK LIKE "Jack" (NO SPACES). strLastName = Trim(strLastName) Range("C2") = strLastName End Sub |
*************************************************************************************
Now watch how it’s done…
Let me know if you have any questions
****************************************************
|






