You can add text to a cell using ampersand “&”. First, find a cell you want to add text to. Next, enter the text or a reference to a cell with text or a number. If you do it for a number if will be formatted to text in the cell with the formula.
You can add text at the beginning or at the end of a cell.
Add text to all cells in column
If you have multiple cells in a column, you can use autofill and the text will be added to all of them.
If you want to and spaces between the cells use the following formula.
=A1&" "&B1&" "&C1
Add text based on cell color
In order to check cell color, we have to use VBA. This is the example we are going to use.
Press Alt + F11 to open the VBA editor and use this procedure to check what indexes have the colors we use in our example. We will do it for cells A1 and A2.
Run this code.
Sub CheckBGColor() MsgBox Range("A1").Interior.ColorIndex MsgBox Range("A2").Interior.ColorIndex End Sub
This example returns the following values: 14 and 3. Now let’s create a function which will name color and add it to the cell.
Create a new module for the current document and enter this code.
Function NameColor(cell As Range) If cell.Interior.ColorIndex = 14 Then NameColor = cell + " green." ElseIf cell.Interior.ColorIndex = 3 Then NameColor = cell + " red." Else NameColor = cell End If End Function
Now, the new function called NameColor appeared. This is the result.