Reversing?!?!

kpark91

Well-known Member
Joined
Jul 15, 2010
Messages
1,582
Just out of curiousity and since this seems to be the most active forum so..

What's the fastest way of reversing only words and sentences? :P
(without using excel's pre-established functions if any..)

Ex)
Hello my name is kpark91

Reversing words: olleH ym eman si 19krapk
Reversing sentences: 19krapk si eman ym olleH


For reversing sentences:
I was thinking along the lines of treating the string as an array of characters..
1) Find length of sentence
2) Loop for integer value of length of sentence divided by 2 (swapping first and last characters, 2nd and 2nd last characters, so on...)


For reversing words:
1) Use Split function to split the words
2) Use the same method as reversing sentences except it's for each word.


I was thinking of using these methods but then I found out excel didn't treat the string as an array of characters :(

Any ideas? :D
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

maninweb

New Member
Joined
May 25, 2010
Messages
21
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. Web
Hi kpark91...

you can try the StrReverse function for reversing words; e.g. s = StrReverse("Hello")

Regards
 

kpark91

Well-known Member
Joined
Jul 15, 2010
Messages
1,582
Cool. I didn't know that kind of function existed.
Thanks.

But what's the code behind it? :P
 

Forum statistics

Threads
1,176,347
Messages
5,902,629
Members
434,983
Latest member
JenniferNash

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
Top