[英]How to add running count to excel cell, which already has text in it?
Would anyone have advise on how to add running count to excel cells, which already have text in them, and without removing the said text.有人会建议如何将运行计数添加到 excel 单元格中,这些单元格中已经有文本,并且不删除所述文本。
Few screenshots will follow to clarify my issue.接下来将很少有截图来澄清我的问题。
I have received a ton of sheets which have a test case name as a text/string in the C column and they are missing a running count from the beginning of the cell (not sure if the "running count" is the correct term).我收到了大量在 C 列中将测试用例名称作为文本/字符串的工作表,并且它们缺少从单元格开头的运行计数(不确定“运行计数”是否是正确的术语)。 In the first screenshot you can see how I need them to be, as well as in the couple first rows of the second screenshot (column C).
在第一个屏幕截图中,您可以看到我需要它们,以及在第二个屏幕截图的第一行(C 列)。 So the original text could be for example "Purchase order" and I want it to be "1. Purchase order" and the next cell would be "2. Purchase order" etc.
所以原始文本可以是例如“采购订单”,我希望它是“1.采购订单”,下一个单元格将是“2.采购订单”等。
I imagine there isn't an already existing function in excel which would solve my problem.我想excel中没有一个已经存在的函数可以解决我的问题。 I have played around with macros and VBA some years ago, but don't have any clue from on top of my head how to solve this.
几年前我玩过宏和 VBA,但我不知道如何解决这个问题。
Perhaps a macro that would go through each cell from the selected column one by one, cut the existing text, add a variable number to the cell and then copy the cut text back there after the variable, then add +1 to the variable before moving to the next cell?也许是一个宏,它会从所选列中逐个遍历每个单元格,剪切现有文本,将变量编号添加到单元格,然后将剪切的文本复制回变量之后,然后在移动之前向变量添加 +1到下一个单元格?
So I somewhat understand the logic how it could be done, but don't have any memory how the syntax and the operators etc. work in VBA.所以我有点理解如何完成它的逻辑,但没有任何记忆语法和运算符等如何在 VBA 中工作。
Thank you in advance.先感谢您。
Not exactly sure what you want from the images, but you can do things like this:不完全确定您想要从图像中得到什么,但您可以执行以下操作:
If cell A1 has 942如果单元格 A1 有 942
and cell B1 has "slices of bread" B1 单元格有“面包片”
Then C1 can have the result "942 slices of bread":那么C1可以得到“942片面包”的结果:
=A1&" "&B1
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.