跳到主要内容

如何在Excel中所有单元格的开头或结尾添加文本?

有时,您可能会发现自己需要在所选内容的每个单元格中添加或附加相同的特定文本。 为每个单元手动执行此操作可能非常乏味且耗时。 幸运的是,有几种更简单的方法可以实现此目的,使您可以更有效地将相同的文本添加到所选内容中所有单元格的开头或结尾。


使用公式将指定的文本添加到所有单元格的开头/结尾

有两个公式可将指定的文本添加到Microsoft Excel中所有选定单元格的开头或结尾。

方法1:&公式

输入 =“ A级:”&A2 在单元格C2中,然后将填充手柄向下拖动到要使用此公式的单元格上。 并且已在所有单元格之前添加了特定文本,请参见屏幕截图:

doc添加特定文本1

方法2:连接公式

输入 =串联(“ A类:”,A2) 在单元格C2中,然后将此公式拖放到您要使用的单元格中,请参见屏幕截图:

doc添加特定文本2

笔记:

1.如果要在每个单元格中添加其他指定的文本,只需替换 A类: 在两个公式中都带有您的文字。

2.的公式 = A2&“:A级” =串联(A2,“:A类”) 将添加 :A级 在单元格的末端。

3.两个公式都不会直接修改选择内容。


将相同的文本添加到 Excel 中每个单元格的特定位置

如何将文本或字符添加到多个单元格的开头,或者如何将文本或字符添加到单元格的末尾,或者在现有文本之间插入文本或字符? 用 添加文本 Kutools for Excel的实用程序,您可以快速应用以下操作: 。 点击即可获得 30 天的全功能免费试用!
doc添加文本6
 
Kutools for Excel:拥有超过 300 个方便的 Excel 插件,在未来 30 天内免费试用,无任何限制。

使用VBA将指定的文本添加到所有单元格的开头/结尾

如果要在选择的每个单元格中直接添加指定的文本,则以下VBA宏将简化您的工作。

1。 选择您要添加指定文本的范围;

2。 按住 其他 + F11 键,然后打开 Microsoft Visual Basic应用程序 窗口。

3。 点击 插页 > 模块,然后将以下VBA代码粘贴到“模块窗口”中。

VBA:在每个单元格的开头添加指定的文本:

Sub AppendToExistingOnLeft()
Dim c As Range
For Each c In Selection
If c.Value <> "" Then c.Value = "CN- " & c.Value 
Next
End Sub

4。 按 F5 运行此宏的键。 并且所有单元格将被添加值 CN- 在单元格内容之前。

doc添加特定文本3

笔记: 1.要在每个单元格的末尾添加一些特定的文本,请应用以下VBA代码。

VBA:在每个单元格的末尾添加指定的文本:

Sub AppendToExistingOnRight()
Dim c as range
For each c in Selection
If c.value <> "" Then c.value = c.value & "-CN" 
Next
End Sub

您将得到以下结果:

doc添加特定文本4

2.您可以更改变量 "CN-" -CN以上代码中的“。


使用 Kutools for Excel 将指定的文本添加到所有单元格的开头/结尾

Kutools for Excel's Add Text 工具将帮助您快速将指定的文本添加到所选内容中每个单元格的开头或结尾。

Kutools for Excel, 与超过 300 方便的功能,使您的工作更加轻松。 

安装后 Kutools for Excel,请执行以下操作:(立即免费下载Kutools for Excel!)

1。 选择您要添加指定文本的范围。

2。 点击 库工具 > Text > Add Text…。 看截图:

doc添加特定文本11

3。在 Add Text 对话框中,输入您需要添加的文本 Text 框。

(1.)如果检查 Before first character 来自 Position 部分,并且特定的文本将添加到所有单元格值的前面,请参见屏幕截图:

doc添加特定文本6

(2.)如果检查 After last character 来自 Position 部分,并将在单元格值的末尾添加特定文本,请参见屏幕截图:

doc添加特定文本7

笔记:

1. Kutools for Excel's Add Text 工具可让您预览“预览”部分中所选内容的更改。

2.如果您检查 Skip non-text cells 选项,此工具不会在具有非文本内容的单元格中添加指定的文本。


使用 Kutools for Excel 将指定文本添加到所有单元格的指定位置

应用 Kutools for Excel's Add Text 功能,您不仅可以将指定的文本添加到单元格的开头或结尾,还可以将指定的文本添加到单元格的指定位置。

安装后 Kutools for Excel,请执行以下操作:(立即免费下载Kutools for Excel!)

1。 选择要向其添加文本的范围,然后单击 库工具 > Text > Add Text.

2。 该 Add Text 将显示对话框,并输入指定的文本并在框中指定要插入文本的特定位置。 看截图:

我在这里输入3 Specify textbox表示在字符串的第三个字符之后添加文本。

doc添加特定文本8

3。 点击 Ok or Apply。 指定的文本已添加到单元格的指定位置。 看截图:

doc添加特定文本9

提示:

(1进 Specify 文本框,您可以输入数字,并用逗号分隔,以同时在多个位置添加文本。
doc添加特定文本12

(2)如果要在每个大写字母之前添加文本,则 1st letter is uppercase 选项 Add Text 实用程序可以为您提供帮助。
doc添加特定文本10

另外,您可以在每个小写字母或每个数字字母之前添加文本。

单击立即下载并免费试用 Kutools for Excel !


演示:将文本添加到所有单元格的开头或结尾


相关文章:

最佳办公生产力工具

🤖 Kutools 人工智能助手:基于以下内容彻底改变数据分析: 智能执行   |  生成代码  |  创建自定义公式  |  分析数据并生成图表  |  调用 Kutools 函数...
热门特色: 查找、突出显示或识别重复项   |  删除空白行   |  合并列或单元格而不丢失数据   |   不使用公式进行四舍五入 ...
超级查询: 多条件VLookup    多值VLookup  |   跨多个工作表的 VLookup   |   模糊查询 ....
高级下拉列表: 快速创建下拉列表   |  依赖下拉列表   |  多选下拉列表 ....
列管理器: 添加特定数量的列  |  移动列  |  切换隐藏列的可见性状态  |  比较范围和列 ...
特色功能: 网格焦点   |  设计图   |   大方程式酒吧    工作簿和工作表管理器   |  资源库 (自动文本)   |  日期选择器   |  合并工作表   |  加密/解密单元格    按列表发送电子邮件   |  超级筛选   |   特殊过滤器 (过滤粗体/斜体/删除线...)...
前 15 个工具集12 文本 工具 (添加文本, 删除字符,...)   |   50+ 图表 类型 (甘特图,...)   |   40+ 实用 公式 (根据生日计算年龄,...)   |   19 插入 工具 (插入二维码, 从路径插入图片,...)   |   12 转化 工具 (小写金额转大写, 货币兑换,...)   |   7 合并与拆分 工具 (高级组合行, 分裂细胞,...)   |   ... 和更多

使用 Kutools for Excel 增强您的 Excel 技能,体验前所未有的效率。 Kutools for Excel 提供了 300 多种高级功能来提高生产力并节省时间。  单击此处获取您最需要的功能...

产品描述


Office Tab 为 Office 带来选项卡式界面,让您的工作更加轻松

  • 在Word,Excel,PowerPoint中启用选项卡式编辑和阅读,发布者,Access,Visio和Project。
  • 在同一窗口的新选项卡中而不是在新窗口中打开并创建多个文档。
  • 每天将您的工作效率提高50%,并减少数百次鼠标单击!

Comments (55)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Bonjour, J'ai besoin d'aide. J'ai un tableau excel dans lequel je veux dans une de mes colonnes que lorsque j'écris NOK la cellule se colore en rouge et les caractères en blanc.
En VBA J'ai déjà tout essayé comme message mais j'ai toujours une erreur. Mon problème se situe au niveau de la première ligne car je ne sais pas quoi écrire. Quand j'inscris NAME il ne fait rien. Quand j'inscris Value il ne fait rien. J'ai essayé TEXTBOX et le nom de la colonne CAISSE mais j'ai toujours une erreur.

If cell.Textboxcaisse = NOK Then
cell.Interior.ColorIndex = 3
cell.Font.ColorIndex = 2
cell.Font.Bold = True
End If
Next
For Each cell In Range("r3:r500")
If cell.Name = OK Then
cell.Interior.ColorIndex = 2
cell.Font.ColorIndex = 1
cell.Font.Bold = True
End If
Next

Merci pour votre aide.
This comment was minimized by the moderator on the site
Hi there,

Do you mean that you want the fill color to turn red and font color to turn white as long as the cell's content is NOK? So, if 10 cells have NOK as content, and the 10 cells are in the column you mentioned, the fill color and font color of all the 10 cells will change?

Also, can you speak English? So I can better understnd your situation. And it will be better if you attach the file with the VBA you created. So that we can help you revise it with higher efficiency.

Thanks in advance.
Amanda
This comment was minimized by the moderator on the site
Thank you!
This comment was minimized by the moderator on the site
the VBA code worked perfectly on Office for Mac
This comment was minimized by the moderator on the site
Me has quitado varias horas de trabajo de encima, mil gracias!!!
This comment was minimized by the moderator on the site
thanks a lot dear for sharing information.
This comment was minimized by the moderator on the site
Thank you! Apend and pre-pend macro works great
This comment was minimized by the moderator on the site
I am trying to change a date formula from mm/dd/yyyy to dd/mm/yyyy. The leading zeros for months and dates less than 10 (two digits) are going away. Anyone have tips on how to easily put them back. I tried using the =month, =day, =year formulas and concatenating them. However, the leading zeros are dropping off. I would manually have to put in the leading zeros. Is there an easy way to do this? We are going to have approximately 1,000 rows of data on our file each month.
This comment was minimized by the moderator on the site
Hi, Amanda, if you want to convert date from mm/dd/yyyy to dd/mm/yyyy, this article https://www.extendoffice.com/documents/excel/4646-excel-convert-dd-mm-yyyy-to-mm-dd-yyyy.html can help you, it list two easiest ways for solving this job.
This comment was minimized by the moderator on the site
I want to make a formula that show in cell text "Profit" when another cell show +digit, and show in that cell "Loss" when another that cell show -digit
This comment was minimized by the moderator on the site
Hi, Manik, use this =IF(B1>0, "Profit", "Loss")
This comment was minimized by the moderator on the site
Thanks a lot!! I was initially using Access but this is so much easier.
This comment was minimized by the moderator on the site
Hello, i want to add text in a formula;

current cell value: ='DAM91-SVC'!$C$47
i want to add text: [MHSV Sales Report 2017 (JAN-DEC).xlsx]

therefore the cell value should read like this in the end: ='[MHSV Sales Report 2017 (JAN-DEC).xlsx]DAM91-SVC'!$C$47

please tell me how will this be done.
thank you
total 1800 cell count need alteration.
This comment was minimized by the moderator on the site
Hello, sorry to read your question so late. Here is a solution but you need to free download Kutools for Excel.

Using the Convert Formula to Text utility to convert the formula cell to text, then apply Add Text utility to add the text string in the Specify position(1), then click Ok. After all cells have been added text, conver them to formula by click Kutools > Content > Convert Text to Formula.
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations