Excel VBA, Trim(), LTrim(), RTrim(), Application.Trim()

 Sub test()

    MsgBox Trim("   apple   ")
    'apple
    MsgBox LTrim("   apple   ")
    'apple   
    MsgBox RTrim("   apple   ")
    '   apple
    MsgBox Trim("a   pple")
    'a   pple
    MsgBox Application.Trim("a   pple")
    'a pple

'Spaces contained in a string are removed.
'However, spaces in middle of the string are left only one space.
        
End Sub

댓글