VB 6.0 - To remove characters from right position with condition in vba

Asked By Balasubramoniyan K on 05-Mar-13 03:50 AM
Hi Team,

This is to remove characters from right position of string using condition in excel vba.

Eg: 

Input
Please find attached Report  for the period May 2012.

Required format
Please find attached Report  for the period.

ie we have to remove from right position upto second space character.

Thanks



Danasegarane Arunachalam replied to Balasubramoniyan K on 06-Mar-13 05:31 AM
Use the Left Function

Private Sub Workbook_Open()
  Dim str As String
  Dim modifiedstring As String
  str = "This is test string"
  modifiedstring = Left(str, Len(str) - 7) ' Last 7 seven chars will be removed
  MsgBox (modifiedstring)

 
End Sub