http://www.extendoffice.com/documents/excel/1146-excel-reverse-string-word-order.html

这个不错:

Reverse text string with formula in Excel

Amazing! Using Tabs in Excel like Firefox, Chrome, Internet Explore 10!

In Excel, you can use a formula to reverse text string. For example, there are some text string as shown as below in Excel:

Step 1. Type this formula =IF(LEN(A1)<1,"",MID(A1,LEN(A1),1))&IF(LEN(A1)<2,"",MID(A1,LEN(A1)-1,1))&IF(LEN(A1)<3,"",MID(A1,LEN(A1)-2,1))&IF(LEN(A1)<4,"",MID(A1,LEN(A1)-3,1))&IF(LEN(A1)<5,"",MID(A1,LEN(A1)-4,1))into B1, and then press Enter button. See screenshot:

Step 2. Copy this formula to other cells by dragging the bottom right corner of the Cell B1. See screenshot:

Note:

1. In this case, each of text string has five characters, so here the formula has five sections. If the text string has six characters, you need to add &IF(LEN(A1)<6,"",MID(A1,LEN(A1)-5,1)) to the end of the formula.

2. If each text string has a different number of characters in the column, you cannot drag the bottom right corner to copy the formula, you need to type the different formulas one by one.

 Reverse text string with VBA

Amazing! Using Tabs in Excel like Firefox, Chrome, Internet Explore 10!

Supposing you have a range of text strings which you want to reverse, such as “add leading zeros in Excel” to “lecxE ni sorez gnidael dda”. You can reverse the text with following steps:

1. Hold down the ALT + F11 keys, and it opens the Microsoft Visual Basic for Applications window.

2. Click Insert > Module, and paste the following macro in the Modulewindow.

Sub ReverseText()
'Updateby20131128
Dim Rng As Range
Dim WorkRng As RangeOn Error Resume Next
xTitleId = "KutoolsforExcel"
Set WorkRng = Application.Selection
Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)For Each Rng In WorkRngxValue = Rng.ValuexLen = VBA.Len(xValue)xOut = ""For i = 1 To xLengetChar = VBA.Right(xValue, 1)xValue = VBA.Left(xValue, xLen - i)xOut = xOut & getCharNextRng.Value = xOut
NextEnd Sub
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
SubReverseText()
'Updateby20131128
DimRngAsRange
DimWorkRngAsRange
OnErrorResume Next
xTitleId = "KutoolsforExcel"
SetWorkRng = Application.Selection
SetWorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
ForEachRng InWorkRng
xValue = Rng.Value
xLen = VBA.Len(xValue)
xOut = ""
Fori = 1 ToxLen
getChar = VBA.Right(xValue, 1)
xValue = VBA.Left(xValue, xLen - i)
xOut = xOut & getChar
Next
Rng.Value = xOut
Next
EndSub

3. Then press F5, a dialog is displayed on the screen, and you need select a range to work with. See screenshot:

4. And then press OK, and all the text strings have been reversed. See screenshot:


 Reverse words separated by interval symbol with VBA

If you have a list of cell words which are separated by commas as this “teacher, doctor, student, worker, driver”, and you want to reverse the words order like this “drive, worker, student, doctor, teacher”. You can also use follow VBA to solve it.

1. Hold down the ALT + F11 keys, and it opens the Microsoft Visual Basic for Applications window.

2. Click Insert > Module, and paste the following macro in the Module window.

Sub ReverseWord()
'Updateby20131128
Dim Rng As Range
Dim WorkRng As Range
Dim Sigh As String
On Error Resume Next
xTitleId = "KutoolsforExcel"Set WorkRng = Application.Selection
Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
Sigh = Application.InputBox("Symbol interval", xTitleId, ",", Type:=2)For Each Rng In WorkRngstrList = VBA.Split(Rng.Value, Sigh)
xOut = ""
For i = UBound(strList) To 0 Step -1
xOut = xOut & strList(i) & Sigh
Next
Rng.Value = xOut
Next
End Sub
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
SubReverseWord()
'Updateby20131128
DimRngAsRange
DimWorkRngAsRange
DimSighAsString
OnErrorResume Next
xTitleId = "KutoolsforExcel"
SetWorkRng = Application.Selection
SetWorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
Sigh = Application.InputBox("Symbol interval", xTitleId, ",", Type:=2)
ForEachRng InWorkRng
strList = VBA.Split(Rng.Value, Sigh)
xOut = ""
Fori = UBound(strList) To0Step-1
xOut = xOut & strList(i) & Sigh
Next
Rng.Value = xOut
Next
EndSub

3. Then press F5, a dialog is displayed on the screen, and you need select a range to work with. See screenshot:

4. And then press Ok, another dialog is popped out for you to specify the interval symbol. See screenshot:

5. Then clcik OK, and you can see the words selected are reverse, see screenshot:


 A handy way to reverse text string or words order with Kutools for Excel

The Kutools for Excel’s Reverse Text Order can help you quickly and conveniently to reverse various text strings. It can do following operations:

Reverse the text from right to left, such as “tap some words” to “sdrow emos pat”;

Reverse the text are separated by space, such as “apple orange grape” to “grape orange apple”;

Reverse the text are separated by semicolon, comma, carriage return or other specific characters.

Kutools for Excel includes more than 120 handy Excel tools. Free to try with no limitation in 30 days. Get it Now.

When you have installed Kutools for Excel, you can do as this:

1. Select the range that you want to reverse.

2. Click Kutools > Text Tools > Reverse Text Order, see screenshot:

3. In the Reverse Text dialog box, select the proper option from Separator which are corresponding with the cell values. And you can preview the results from the Preview Pane. See screenshot:

4. Then click OK or Apply. All the cell contents have been revered by space in this example. See screenshots:

Note:Checking Skip non-text cells to prevent you reversing the numbers in selected range.

To know more about this function, please visit Reverse Text Order.


Related article:

How to flip the first and last name in cells in Excel?


Kutools for Excel

More than 120 Advanced Functions for Excel 2013, 2010, 2007 and Office 365.

          

Comments

+7# Vineet 2014-02-04 06:07

This is absurd. So much code to perform just a simple task of reversing the string?  
Just 3 line function needs to be added in the module as below:

Function strrev(strValue As String)
strrev = StrReverse(strValue)
End Function

Now the formula =strrev(A1) can be used in Excel sheet. This works since StrReverse is an inbuilt function of VBA.

Reply | Reply with quote | Quote

-1# Faseeh 2014-05-28 11:52

Another one...

Function InvertText(str As String)
'By Faseeh Muhammad
Dim m As Integer
For m = Len(str) To 1 Step -1
countRepp = countRepp & Mid(str, m, 1)
Next m
End Function

Reply | Reply with quote | Quote

-1# Faseeh 2014-05-28 11:56

Sorry a little editing

Function InvertText(str As String)
'By Faseeh Muhammad
Dim curr As String
Dim m As Integer
For m = Len(str) To 1 Step -1
countRepp = countRepp & Mid(str, m, 1)
Next m
Inverttext
End Function

Reply | Reply with quote | Quote

Refresh comments list

几种用EXCEL实现字符串的颠倒的方法相关推荐

  1. iOS获取自1970年毫秒数使用OC和swift两种语法,返回字符串

    iOS获取自1970年毫秒数使用OC和swift两种语法,返回字符串 oc的话,我们定义一个category分类,对谁分类,对NSDate分类,对外暴露一个类方法,只要导入头文件,即可使用. @int ...

  2. js中string字符串转换为JSON对象 - 方法大全(4种)

    js中string字符串转换为JSON对象 - 方法大全(4种) jQuery插件支持的转换方式: 示例: //jQuery.parseJSON(jsonstr),可以将json字符串转换成json对 ...

  3. [转]EXCEL截取字符串中某几位的函数——LeftMIDRight及Find函数的使用

    原文地址:http://blog.sina.com.cn/s/blog_3f136a180102ymq5.html EXCEL截取字符串中某几位的函数 --Left MID Right及Find函数的 ...

  4. 《Java安全编码标准》一2.11 IDS10-J不要拆分两种数据结构中的字符串

    2.11 IDS10-J不要拆分两种数据结构中的字符串 在历史遗留系统中,常常假设字符串中的每一个字符使用8位(一个字节,Java中的byte).而Java语言使用16位表示一个字符(Java中的Ch ...

  5. excel转java 常量_【转】八种常见Excel错误提示及解决方法

    Excel经常会显一些错误值信息,如#N/A!.#VALUE!.#DIV/O!等等.出现这些错误的原因有很多种,最主要是由于公式不能计算正确结果.例如,在需要数字的公式中使用文本.删除了被公式引用的单 ...

  6. 【杂项】通过Excel为字符串产生条码

    [杂项]通过Excel为字符串产生条码 1, 前提条件. 在电脑上安装字体C39HrP48DhTt, 具体方法见笔者相关文章. 2, 功能展示 建立一个新的Excel文件. 在原始字符串列B3里输入字 ...

  7. excel find 字符串批量查找

    excel find 字符串批量查找 查找字符:15001001(位置A1) 内容:https://editor.csdn.net/md/?id=15001001(位置B1) 查找公式:FIND(A1 ...

  8. matlab悬置非线性位移计算公式,一种基于Excel的电动车动力总成悬置工况力数据处理方法与流程...

    本发明涉及计算机辅助工程(CAE)技术领域,具体涉及一种基于Excel的电动车动力总成悬置工况力数据处理方法. 背景技术: 动力总成的28工况力与位移分析是基于GM提出的传统车28工况修改而来,其分解 ...

  9. android字符串块,一种Android系统字符串提取及合并方法与流程

    本发明涉及字符串提取及合并方法,尤其涉及一种Android系统字符串提取及合并方法. 背景技术: 随着智能通讯终端的日益普及,采用Android系统的智能通讯终端设备越来越走向世界各地,而对于多国语言 ...

最新文章

  1. win2003登陸及關機設定
  2. 测序技术有4个指标:读长、成本、准确度、通量
  3. 大数据WEB阶段 Maven与SSM框架整合
  4. Spring Schedule定时关单快速入门
  5. apache-storm分布式计算(drpc)开发心得
  6. 服务器压力测试怎么做_做手游怎么选服务器?
  7. 为什么网络安全领域需要更多的女性?
  8. RTCP协议解析--RR
  9. 那些开挂的人,如何打败50%的竞争者?
  10. Gmail企业邮箱让中小企业免费拥有企业邮箱
  11. Matplotlib-自定义虚线样式
  12. 磷脂PEG磷脂,DSPE-PEG-DSPE
  13. 【ARM-Linux开发】【DSP开发】AM5728介绍
  14. Unity与FBX--为什么使用FBX文件
  15. ObjectARX安装小结
  16. 哪些服务器支持 9200系列CPU,核心暴增、修复漏洞:intel 英特尔 发布 Xeon Platinum 9200和8200系列 处理器...
  17. STM32 HAL库 CUBEMX FPU 和 DSP库
  18. idea常用快捷键图文_如何在Word中的自动图文集词条中添加快捷键
  19. 天龙八部哪个服务器里面人数最多的,天龙八部怀旧服:不删档各大门派人数出来了!你猜哪个门派人多?...
  20. python英汉词典

热门文章

  1. 阿里巴巴JAVA岗发布+内部面试题(含P5-P7)
  2. CSS 3.0实现加载动画
  3. 历时3年研发,OPPO发布首颗自研NPU芯片:马里亚纳 MariSilicon X
  4. cad批量打印_BIM智库 | CAD批量打印软件免费版
  5. Doxygen 注释语法和使用
  6. Mdb文件的还原成数据库文件(亲测有效)
  7. 学习报告(19.10.15-19.11.12)
  8. a星算法实现8数码问题c语言,A星算法求八数码问题实验报告.doc
  9. echarts世界地图更新,添加十段线
  10. 搞搞字节,byte的小知识