简体   繁体   English

如何将运行计数添加到已经有文本的excel单元格?

[英]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.采购订单”等。

Screenshot 1.截图 1。

Screenshot 2.截图 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

Not sure neither if running count is the right term, but you can do it with a helper column and an easy formula:不确定运行计数是否是正确的术语,但是您可以使用辅助列和简单的公式来做到这一点:

在此处输入图像描述

=COUNTIF($C$2:C2;C2)&". "&C2

Then you can copy/paste as values and delete helper column然后您可以复制/粘贴为值并删除帮助列

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将单元格文本与包含Excel中已有文本的另一个单元格合并? - How to join a cell text with another cell that contains text already in excel? 跳过已经有一些文本的单元格后如何在excel列中填充系列 - How to fill series in the column of excel after skipping the cell (s) which already have some text 如何在Ruby on Rails中使用axlsx将更多列中的数据添加到已经在Excel中编写的行中 - How to add data in more columns to a row which has already been written in Excel using axlsx in Ruby on Rails 如果字符串已经有引号,如何在 excel 中连接字符串和单元格值? - how to concatenate a string and cell value in excel if the string already has quotes? 如何检查单元格中的实际文本是否已经存在于Excel中的列中 - How to check if the actual text in the cell already exists in the column in excel 填充一个或多个单元格时如何自动向excel单元格添加文本? - How to add a text automatically to an excel cell when a cell or cells are filled? 如果单元格中有内容,如何停止Excel VBS运行 - How to stop Excel VBS running if cell has contents Python 2.7:如何读取在单元格内有表格的excel - Python 2.7 : How to read an excel which has a table inside a cell 如何读取字符计算Excel单元格的“文本长度”? - How to read characters Count “Text Length” for Excel cell? 如何计算包含包含特定文本的单元格的行数? - How to count the number of rows which contain a cell containing specific text?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM