英文:
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)
。
结果:
英文:
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:
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论