2015-04-06 102 views
1

首先我想說的是,我已經在SO上進行過搜索,並且發現了一些類似於我的問題,但它們處理的是數字而不是文本。如何基於Excel中其他單元格的內容爲一個單元格創建文本內容?

另一件事是,我不知道我想要做什麼需要公式或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?如果可能的話,任何具體的例子都會很棒!

+3

帶字符串連接的公式:'=「這個項目...」&B12&「並且可以...」' –

回答

2

這應該正是你要尋找的:

=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) 

你只是使用連擊功能,這些單元格的值添加到一個字符串。字符串的任何部分都應該用引號引起來,並且每當您想要包含另一個單元格時,只需關閉當前引用,添加逗號,空格和逗號。然後可以用括號關閉連接或啓動另一個字符串。

+0

使用連接而不是僅僅用引號和& (即=「這是」&b1&「,然後這個......」&C1)? – BruceWayne

2

除了Concatenate之外,您還可以使用引號和逗號。

您可以輸入這個地址欄:

="This item has a weight of " & B12 & " and can be found in the following colors" & D12 ". It can be used for " & E12 

...等。只需將您的不變文本放在引號中,用「&」分開並放置單元格引用。另外請記住,如果要向上/向下拖動該公式(錨點是單元格引用中的$,即$ B $ 12),則可以使用錨點。

2

可以使用concatenate function來實現這一點:

enter image description here

你可以把這個公式中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,".") 



你去那裏。

相關問題