Name break into half and reverse to upper case

S

shrinivasmj

Need to Reverse the name by uppercase and with comma without space afe
comma, to below conduction

need to reverse name by half part like below

ALL UPPER CASE
1 to 3 words reverse 1 last word
3 to 5 words reverse 2 last word
6 words above reverse 3 last word

name EG ( mahesh m.k.l. ) There are 4 words we take space and dot a
one word.


EG NAME INOUT AND OUTPUT

Srinivas SRINIVAS
srinivas m M,SRINIVAS

srinivas m.j. J,SRINIVAS M.

srinivas m.j.h. J.H,SRINIVAS M.

srinivas m. j. h. k. H. K,SRINIVAS M. J.

srinivas m. j. h. k. l. H. K. L,SRINIVAS M. J.

Above are input and out put EG.
need to take as it is input with reverse uppercas
 
C

Claus Busch

Hi,

Am Mon, 29 Oct 2012 10:47:47 +0000 schrieb shrinivasmj:
EG NAME INOUT AND OUTPUT

Srinivas SRINIVAS
srinivas m M,SRINIVAS

srinivas m.j. J,SRINIVAS M.

srinivas m.j.h. J.H,SRINIVAS M.

srinivas m. j. h. k. H. K,SRINIVAS M. J.

srinivas m. j. h. k. l. H. K. L,SRINIVAS M. J.

try it with VBA (modify to suit):

Sub RevStr()
Dim c As Range
Dim LRow As Long
Dim mySearch As Integer
Dim Start As Integer

LRow = Cells(Rows.Count, 1).End(xlUp).Row
For Each c In Range("A1:A" & LRow)
If InStr(c, ".") = 0 And InStr(Trim(c), " ") > 0 Then
mySearch = 2
Else
mySearch = Len(c) - Len(Replace(c, ".", "")) + 1
End If

Select Case mySearch
Case 2
Start = WorksheetFunction.Find(" ", c) + 1
c = Mid(c, Start, 99) & ", " & Left(c, Start - 2)
Case 3, 4
c = WorksheetFunction.Substitute(c, ".", "#", 1)
Start = WorksheetFunction.Find("#", c) + 1
c = Mid(c, Start, 99) & ", " & Left(c, Start - 2) & "."
Case 5, 6, 7, 8, 9, 10
c = WorksheetFunction.Substitute(c, ".", "#", 2)
Start = WorksheetFunction.Find("#", c) + 1
c = Mid(c, Start, 99) & ", " & Left(c, Start - 2) & "."
End Select

c = UCase(Trim(c))

Next
End Sub


Regards
Claus Busch
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top