Revers name

sksanjeev786

Well-known Member
Joined
Aug 5, 2020
Messages
961
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hi Team,

I need a name in reverse formate as of now I can able to do with 2 words but while trying with 3 words not getting correct solution

Output : Verma Kumar Raj

Excel.xls
FG
62Raj Kumar VermaKumar Verma Raj
Test (3)
Cell Formulas
RangeFormula
G62G62=MID(F62&" "&F62,FIND(" ",F62)+1,LEN(F62))
 
Just for fun, a Power Query way of doing it.

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    Reverse = Table.TransformColumns(Source,{{"Column1", each Text.Combine(List.Reverse(Text.Split(_, " "))," ")}})
in
    Reverse

Unwind with formulas and VBA.xlsm
GH
1Column1Column1
2Raj Kumar VermaVerma Kumar Raj
Sheet2
 
Upvote 0

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Yet more formula options. :eek:

B1 if you have the TEXTSPLIT function in your 365 version.
B2 if not (allows for up to 9 names)

22 05 03.xlsm
AB
1Raj Kumar VermaVerma Kumar Raj
2Raj Kumar VermaVerma Kumar Raj
Reverse
Cell Formulas
RangeFormula
B1B1=LET(ts,TEXTSPLIT(A1," "),TEXTJOIN(" ",,SORTBY(ts,SEQUENCE(,COLUMNS(ts)),-1)))
B2B2=TRIM(CONCAT(LEFT(RIGHT(SUBSTITUTE(" "&A2," ",REPT(" ",100)),100*SEQUENCE(9)),100)))
 
Upvote 0
Another way:
Book1
AB
1Raj Kumar VermaVerma Raj Kumar
Sheet1
Cell Formulas
RangeFormula
B1B1=LEFT(TRIM(RIGHT(SUBSTITUTE(A1," ",REPT(" ",100)),100))&" "&A1, LEN(A1))
 
Upvote 0
More options for office 365:
工作簿1
ABC
1Raj Kumar VermaVerma Raj Kumar
2Verma Raj Kumar
3Verma Raj Kumar
4
Sheet1
Cell Formulas
RangeFormula
B1B1=TEXTAFTER(TEXTBEFORE(A1&" "&A1," ",5)," ",2)
B2B2=TEXTJOIN(" ",,CHOOSECOLS(TEXTSPLIT(A1," "),{3,1,2}))
B3B3=TEXTAFTER(A1," ",2)&" "&TEXTBEFORE(A1," ",2)
 
Upvote 0
@Phuoc @shaowu459
I don't believe any of those formulas produce the result that the OP is looking for
Output : Verma Kumar Raj

The result shown in the mini-sheet in post 1 ..
while trying with 3 words not getting correct solution


Also, another UDF (only works up to 9 words but I' assuming that should be enough to reverse a name)

VBA Code:
Function RevWords(s As String) As String
  RevWords = Join(Application.Index(Split(s), 0, Split(StrReverse(Join(Application.Transpose(Evaluate("row(1:" & UBound(Split(s)) + 1 & ")")))))))
End Function

22 05 03.xlsm
AF
1Raj Kumar VermaVerma Kumar Raj
Reverse
Cell Formulas
RangeFormula
F1F1=RevWords(A1)
 
Last edited:
Upvote 0
Oh, sorry. I copied data from post #13:oops:
:biggrin: Easy enough to do that sort of thing.

Your idea of using CHOOSECOLS though (I'm still not very used to the new functions) does provide a shortening of one of my earlier suggestions.
Here assuming less than 100 words. :eek:

22 05 03.xlsm
AB
1Raj Kumar VermaVerma Kumar Raj
Reverse
Cell Formulas
RangeFormula
B1B1=TEXTJOIN(" ",,CHOOSECOLS(TEXTSPLIT(A1," "),SEQUENCE(,99,99,-1)))
 
Upvote 0
T
@Phuoc @shaowu459
I don't believe any of those formulas produce the result that the OP is looking for


The result shown in the mini-sheet in post 1 ..



Also, another UDF (only works up to 9 words but I' assuming that should be enough to reverse a name)

VBA Code:
Function RevWords(s As String) As String
  RevWords = Join(Application.Index(Split(s), 0, Split(StrReverse(Join(Application.Transpose(Evaluate("row(1:" & UBound(Split(s)) + 1 & ")")))))))
End Function

22 05 03.xlsm
AF
1Raj Kumar VermaVerma Kumar Raj
Reverse
Cell Formulas
RangeFormula
F1F1=RevWords(A1)
Thank you so much peter for your help on this?
 
Upvote 0
:biggrin: Easy enough to do that sort of thing.

Your idea of using CHOOSECOLS though (I'm still not very used to the new functions) does provide a shortening of one of my earlier suggestions.
Here assuming less than 100 words. :eek:

22 05 03.xlsm
AB
1Raj Kumar VermaVerma Kumar Raj
Reverse
Cell Formulas
RangeFormula
B1B1=TEXTJOIN(" ",,CHOOSECOLS(TEXTSPLIT(A1," "),SEQUENCE(,99,99,-1)))
Wow!!! With minimum function… super cool…
 
Upvote 0

Forum statistics

Threads
1,223,355
Messages
6,171,608
Members
452,411
Latest member
sprichwort

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top