Skip to main content

Posts

Showing posts with the label Use of Trim in excel in different ways

Trim string from sentence,Use of Trim in different Ways in excel

Trim string from sentence in excel Public Function trimtwo(ByVal r As Range) As String Dim str As String str = r(1, 1) Dim Flag As Boolean Flag = False Dim indexof As Integer indexof = InStr(str, "Shri") If indexof Then str = Mid(str, indexof + 4, Len(str)) Flag = True End If indexof = InStr(str, "SHRI") If indexof Then str = Mid(str, indexof + 4, Len(str)) Flag = True End If indexof = InStr(str, "Smt.") If indexof Then 'str = Mid(str, 1, 1) & Mid(str, indexof + 5, Len(str)) str = Mid(str, indexof + 5, Len(str)) Flag = True End If indexof = InStr(str, ",") If indexof Then str = Mid(str, 1, indexof - 1) End If str = Trim(str) If Flag Then indexof = InStr(str, " ") If indexof Then str = Mid(str, 1, indexof - 1) & Mid(str, indexof + 1, Len(str)) End If End If trimtwo = str End Function Public Function trimone(ByVal r As