如何根据 Excel 中其他单元格的内容为一个单元格创建文本内容?
How to create text content for one cell based on other cells's content in Excel?
首先我想说的是,我在 SO 上搜索过这个,我发现了一些与我的类似的问题,但它们更多地涉及数字而不是文本。
另一件事是我不确定我想做的事情是否需要公式或VBA,所以我认为询问它会帮助我理解这一点。
我需要做的是:我有一个 excel 电子表格,其中每一行(产品)都有许多包含文本(规格)的列。我需要添加一个新列来描述产品,其中应该有一些预制文本和一些来自其他列的文本。
这些描述之一的示例:
This item has a weight of (value of cell B12) and can be found in the following colors: (value of cell D12). It can be used for (value of cell E12) and has a price of (value of cell F12)
实现类似目标的最佳方法是什么?公式? VBA?如果可能的话,任何具体的例子也很棒!
这应该正是您要查找的内容:
=CONCATENATE("This item has a weight of ", B12, "and can be found in the following colors", D12,". It can be used for ", E12, "and has a price of ", F12)
您只是使用连接函数将这些单元格的值添加到一个字符串中。字符串的任何部分都应该用引号引起来,每当您想包含另一个单元格时,只需关闭当前引号,添加一个逗号、一个 space,然后再添加一个逗号。然后您可以用括号结束连接或开始另一个字符串。
除了连接之外,您还可以只使用引号和逗号。
您可以在地址栏输入:
="This item has a weight of " & B12 & " and can be found in the following colors" & D12 ". It can be used for " & E12
...等只需将不变的文本放在引号中,用“&”分隔并放置单元格引用。另外请记住,如果您想拖动该公式 up/down,您可以使用锚点(锚点是单元格引用中的 $,即 $B$12)。
您可以使用 concatenate function 来实现:
你可以把这个公式放在G2中,然后复制并向下拖动。
=CONCATENATE("This item has a weight of ", B2, " and can be found in the following colors ", D2,". It can be used for ",E2, " and has a price of ", F2,".")
给你。
首先我想说的是,我在 SO 上搜索过这个,我发现了一些与我的类似的问题,但它们更多地涉及数字而不是文本。
另一件事是我不确定我想做的事情是否需要公式或VBA,所以我认为询问它会帮助我理解这一点。
我需要做的是:我有一个 excel 电子表格,其中每一行(产品)都有许多包含文本(规格)的列。我需要添加一个新列来描述产品,其中应该有一些预制文本和一些来自其他列的文本。
这些描述之一的示例:
This item has a weight of (value of cell B12) and can be found in the following colors: (value of cell D12). It can be used for (value of cell E12) and has a price of (value of cell F12)
实现类似目标的最佳方法是什么?公式? VBA?如果可能的话,任何具体的例子也很棒!
这应该正是您要查找的内容:
=CONCATENATE("This item has a weight of ", B12, "and can be found in the following colors", D12,". It can be used for ", E12, "and has a price of ", F12)
您只是使用连接函数将这些单元格的值添加到一个字符串中。字符串的任何部分都应该用引号引起来,每当您想包含另一个单元格时,只需关闭当前引号,添加一个逗号、一个 space,然后再添加一个逗号。然后您可以用括号结束连接或开始另一个字符串。
除了连接之外,您还可以只使用引号和逗号。
您可以在地址栏输入:
="This item has a weight of " & B12 & " and can be found in the following colors" & D12 ". It can be used for " & E12
...等只需将不变的文本放在引号中,用“&”分隔并放置单元格引用。另外请记住,如果您想拖动该公式 up/down,您可以使用锚点(锚点是单元格引用中的 $,即 $B$12)。
您可以使用 concatenate function 来实现:
你可以把这个公式放在G2中,然后复制并向下拖动。
=CONCATENATE("This item has a weight of ", B2, " and can be found in the following colors ", D2,". It can be used for ",E2, " and has a price of ", F2,".")
给你。