跳到主要内容

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

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


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

Excel 中的快速填充是一种智能工具,可在检测到模式时自动填充数据。当您有所需输出的示例时,此功能对于向单元格添加文本特别有用。

假设你需要 在 A 列的姓名前添加“Dr.”。以下是如何使用快速填充来实现此目的:

  1. 确保您的数据位于一列中,并且下一列为空。

  2. 输入第一个示例 “博士。” 添加到下一列的第一个单元格中,然后点击 输入.

  3. 媒体 按Ctrl + E 自动填充列中的其余单元格 “博士。” 为名称添加前缀。

    提示: 您也可以点击 时间 功能区上的选项卡,然后选择 Flash填充 如果您更喜欢使用功能区界面进行 Excel 操作,也可以获得相同的结果。

笔记: 在名称后添加特定文本,例如附加 “,人力资源” 要指示人力资源部门,您可以使用相同的方法:


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

在本节中,我们将学习如何使用 Excel 公式在单元格的开头或结尾轻松插入特定文本或字符。

将指定文本添加到单元格的开头

要将文本添加到 Microsoft Excel 中单元格的开头,您可以使用 Excel 公式将指定的字符串与单元格引用连接起来。假设你需要 将“Class A:”添加到 A 列中的名称前面。以下是如何应用公式来实现此目的:

  1. 选择要输出名字前缀为“的单元格”A类: ".

  2. 根据您的喜好输入任何这些公式并点击 输入 查看第一个结果(这里我以第一个公式为例):
    ="Class A: "&A2
    =CONCATENATE("Class A: ", A2)
    =CONCAT("Class A: ", A2)
    提示: 在这些公式中,“A类: " 是添加到名称中的前缀,并且 A2 是包含您要修改的名称的第一个单元格。随意替换”A类: ”并调整 A2 以满足您的特定需求。

  3. 将填充柄向下拖动到要应用此公式的单元格。

笔记:

  • 公式不会修改原始数据。
  • 为简单起见,请将要添加的文本放置到特定单元格中(例如 E2),然后合并两个单元格。 提示: 前置文本的单元格地址用 $ 符号锁定,以防止在复制公式时发生更改。


将指定文本添加到单元格末尾

要将文本附加到 Microsoft Excel 中的单元格末尾,您可以使用 Excel 公式将单元格引用与指定字符串连接起来。想象一下你需要 将“-Class A”附加到 A 列中的名称。请按照以下步骤有效地利用公式:

  1. 选择您希望名称后缀为“的单元格” - A级” 来显示。

  2. 根据您的喜好选择其中一个公式并按 输入 查看结果(这里,我将使用第一个公式进行演示):
    =A2&" - Class A"
    =CONCATENATE(A2, " - Class A")
    =CONCAT(A2, " - Class A")
    提示: 在这些公式中,“ - A级" 是附加到名称后的文本,并且 A2 指包含您要修改的名称的初始单元格。我们鼓励您更换“ - A级”并调整 A2 根据需要满足您的特定要求。

  3. 通过向下拖动填充柄将公式扩展到所需的单元格。

笔记:

  • 公式不会修改原始数据。
  • 为简单起见,请将要添加的文本放置到特定单元格中(例如 E2),然后合并两个单元格。 提示: 前置文本的单元格地址用 $ 符号锁定,以防止在复制公式时发生更改。


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

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

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

在本节中,我们将探索一种简单的 VBA 方法,将指定的文本直接添加到一个或多个选定范围内的所有单元格的开头或结尾。

将指定文本添加到单元格的开头
  1. 选择要将指定文本添加到所有单元格开头的范围。
  2. 按住 Alt + F11键 在Excel中打开键 Microsoft Visual Basic应用程序 窗口。
  3. 点击 插页 > 模块,然后将以下VBA代码粘贴到 模块 窗口。
    Sub PrependToSelectedCells()
        Dim c As Range
        For Each c In Selection
            If c.Value <> "" Then c.Value = "EXCL-" & c.Value 
        Next
    End Sub

    请注意: 此代码为所有选定的单元格添加前缀 “排除-”。确保在将代码中的示例文本应用到工作表之前将其替换为您需要的实际文本。

  4. F5 运行此宏的键。

结果

价值 “排除-” 将被添加到所有选定单元格的内容之前。

提示: 如果你愿意的话 将修改后的值放入右侧相邻列中 不要直接将文本添加到原始值的开头,而是使用以下代码:

Sub PrependToRightOfSelectedCells()
    Dim c As Range
    For Each c In Selection
        If c.Value <> "" Then c.Offset(0, 1).Value = "EXCL-" & c.Value
    Next c
End Sub

将指定文本添加到单元格末尾
  1. 选择要将指定文本添加到所有单元格末尾的范围。
  2. 按住 Alt + F11键 在Excel中打开键 Microsoft Visual Basic应用程序 窗口。
  3. 点击 插页 > 模块,然后将以下VBA代码粘贴到 模块 窗口。
    Sub AppendToSelectedCells()
        Dim c As Range
        For Each c In Selection
            If c.Value <> "" Then c.Value = c.Value & "-XS"
        Next
    End Sub

    请注意: 该宏附加 “-XS” 每个选定单元格的内容。确保更换 “-XS” 在工作表中运行宏之前,使用您希望附加到单元格内容的特定后缀。

  4. F5 运行此宏的键。

结果

价值 “-XS” 将附加到所有选定单元格的内容中。

提示: 如果你愿意的话 将修改后的值放入右侧相邻列中 不要直接将文本添加到原始值的末尾,而是使用以下代码:

Sub AppendToRightOfSelectedCells()
    Dim c As Range
    For Each c In Selection
        If c.Value <> "" Then c.Offset(0, 1).Value = c.Value & "-XS"
    Next c
End Sub

使用 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