在Excel中通过VBA编程来处理文本或数字的字符顺序。

huangapple go评论85阅读模式
英文:

The order of characters of a text or number in excel via VBA coding

问题

I recently works with excel. I need to copy some tables frome a Persian word file to excel. When I do this, the order of characters of texts and numbers changes. For example 1234 changes to 4321 and esfahani becomes inahafse. I need an vba program to reorder the text and numbers to the original order after pasting.

因为我是Excel的初学者,我一个一个字符地改变了字符的顺序。我需要一个程序,可以帮助我自动改变字符的顺序。同时,我想学习如何自己编写VBA代码,因此需要一些入门指导。

英文:

I recently works with excel. I need to copy some tables frome a Persian word file to excel. When I do this, the order of characters of texts and numbers changes. For example 1234 changes to 4321 and esfahani becomes inahafse. I need an vba program to reorder the text and numbers to the original order after pasting.
How can I write these codes?

Because I am beginner in excel, I changed the order of characters one by one. I need a program that help me to change the order automaticly.Also I would like to learning writing the vba codes by myself, and therefore need to guidance for beginning.

答案1

得分: 2

以下是要翻译的内容:

以下功能将基于输入返回文本的反转字符串:

Function reverse_string(text As String) As String
    reverse_string = StrReverse(text)
End Function

要使用此功能,您需要将以上代码粘贴到工作簿中的新模块中。

然后,您可以在单元格内使用该功能,例如 =reverse_string(A1)

结果:

在Excel中通过VBA编程来处理文本或数字的字符顺序。

英文:

The following function will return a reversed string of text, based on an input:

Function reverse_string(text As String) As String
    reverse_string = StrReverse(text)
End Function

To use the function, you'll need to paste the above code into a new Module within your workbook.

Then, the function will be available to use within a cell, e.g. =reverse_string(A1)

Result:

在Excel中通过VBA编程来处理文本或数字的字符顺序。

huangapple
  • 本文由 发表于 2023年7月13日 13:29:46
  • 转载请务必保留本文链接:https://go.coder-hub.com/76676187.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定