在Excel中排序文本和数字。

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

Sort Text and Number in Excel

问题

我想要以某种方式创建一个宏或某种函数来按照以下顺序对B列进行排序:首先是PT-,然后是PC-,然后是数字从最小到最大的形式。
示例:PT-1, PT-2, PT-3, PC-1, PC-2, PC-3。
在Excel中排序文本和数字。

我希望它看起来像这样
在Excel中排序文本和数字。

英文:

I want to some how create a Macro or some kind of function to sort Column B with PT- first then PC- then the number form smallest to largest
Exp: PT-1,PT-2,PT-3,PC-1,PC-2,PC-3.
在Excel中排序文本和数字。

I want it to look like this
在Excel中排序文本和数字。

答案1

得分: 1

VBA不需要用于此操作。您可以使用内置的排序功能,但由于按字母顺序排列时“PC”在“PT”之前,您需要一个辅助列,将“PT”转换为在“PC”之前的内容。

您可以使用SUBSTITUTE函数将“T”替换为“A”,然后按照这个辅助列进行排序。

公式:

=SUBSTITUTE([@Your_Column_Name],"T","A")

英文:

VBA is not needed for this. You can use the built in sorting functionality but because PC comes before PT alphabetically, you need a helper column where PT is transformed into something that comes before PC.

You can use SUBSTITUTE to replace the T with A and then sort by this helper column.

在Excel中排序文本和数字。

The formula:

=SUBSTITUTE([@Your_Column_Name],"T","A")

huangapple
  • 本文由 发表于 2023年7月17日 12:37:04
  • 转载请务必保留本文链接:https://go.coder-hub.com/76701517.html
匿名

发表评论

匿名网友

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

确定