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))
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Consider calling a function, then it won't matter how many words you want to reverse. In a standard module:
VBA Code:
Function ReverseWordOrder(strIn As String) As String
Dim ary() As String, strOut As String, i As Integer

ary() = Split(strIn)
For i = UBound(ary) To 0 Step -1
   ReverseWordOrder = ReverseWordOrder & ary(i) & " "
Next

End Function
Then fill down
=ReverseWordOrder(A1) <<change to your cell address.
 
Upvote 0
Solution
Unwind with formulas and VBA.xlsm
AB
1Raj Kumar VermaVerma Kumar Raj
Sheet2
Cell Formulas
RangeFormula
B1B1=LET(x,FILTERXML("<a><b>" & SUBSTITUTE(A1," ","</b><b>") & "</b></a>","//b"),c,COUNTA(x),s,SEQUENCE(c,,c,-1),TEXTJOIN(" ",1,INDEX(x,s)))
 
Upvote 0
Another option, for 365 only
+Fluff 1.xlsm
AB
1
2Raj Kumar VermaVerma Kumar Raj
Main
Cell Formulas
RangeFormula
B2B2=LET(f,FILTERXML("<k><m>"&SUBSTITUTE(A2," ","</m><m>")&"</m></k>","//m"),TEXTJOIN(" ",,SORTBY(f,SEQUENCE(ROWS(f),,,-1))))
 
Upvote 0
Those formulas make my head spin! :sick:
Please do let us know which way you go and mark this as solved when you're happy with the result.
 
Upvote 0

Forum statistics

Threads
1,223,355
Messages
6,171,610
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