Home  >  Article  >  How to enter text and formulas into cells in Microsoft Excel

How to enter text and formulas into cells in Microsoft Excel

PHPz
PHPzforward
2023-04-23 08:43:064318browse

Adding formulas to cells in Excel is easy. Adding text is even easier. But how to add text and formula at the same time in one cell? Tried and failed? Well, not anymore, when Geek Page is here to help you.

In this article, we will detail how to easily add both text and formulas to a cell in an Excel worksheet with the help of multiple examples. You can make your content dynamic, so your various requirements for this can be easily fulfilled by following the steps detailed in our article. Hope you like it!

Example Scenario

Suppose you have the following Excel table, which contains the Length column and the Width column. You need to fill the Area column with the text Area is of the rectangle. Where should be replaced with the actual product of length and width to calculate the area.

如何在 Microsoft Excel 中的单元格内添加文本和公式

This is just a sample scenario. By following the solution detailed here, you can include any text and any formula in the cells of your Excel worksheet.

Solution

Step 1: First, enter a = symbol. Then, if you are typing text, enclose it in double quotes. To connect a formula to it, or add a variable in between, or add any dynamics, use the Connectionoperator&.

For example, in the example scenario mentioned in this article, you would place the rectangular text area first. So you need to double click on your cell and write the content as = "The rectangular area is". We enclose this part in double quotes because it is a text.

Now we need to calculate the area and append it to the text. So, put the concatenation operator & next. Then write the formula PRODUCT(A2, B2). PRODUCT formula will calculate the product of the given 2 cell values.

So, for this particular case, your final cell content will look like this.

="矩形的面积是" & PRODUCT(A2,B2)

Note: Dynamic means something that changes its value. For example, Area varies based on length and width. Dynamic content does not have double quotes. Static means something that does not change its value. For example, text content is static and should be enclosed in double quotes.

如何在 Microsoft Excel 中的单元格内添加文本和公式

Step 2: After formatting all the cell contents, press Enter, you can see the area of ​​the rectangle Calculated correctly and value replaced successfully.

如何在 Microsoft Excel 中的单元格内添加文本和公式

Step 3: You can click on the cell and then click and drag the cell down in the lower right corner of the cell to apply the same formula and text to all cells in the same column.

如何在 Microsoft Excel 中的单元格内添加文本和公式

Step 4 : Below is a screenshot showing how the formula is applied to the entire column .

如何在 Microsoft Excel 中的单元格内添加文本和公式

Step 5: Now let’s make your cells more dynamic. Suppose you want the text in cell to be formatted as a rectangular area with Length = and Width = as . Here we are replacing 3 values. 2 variables, namely length and width, and 1 formula, namely the product of length and width. In this case, the content inside the cell should look like this.

="Length= " & A2 & " 和 Width = " & B2 & " 的矩形区域是 " & PRODUCT(A2,B2)

Explanation

  1. First, I placed the = operator.
  2. Then enclose the text content in double quotes. That is, a rectangular area of ​​ length = is enclosed in double quotes.
  3. Next, I placed a & character to connect the dynamic content.
  4. Then include dynamic content by giving a cell id which is the length of the rectangle.
  5. Next, I need to put another & because I want to append a text.
  6. Then write the text again and surround it with double quotes. This time the text is " and Width = ".
  7. Similarly, & B2 & is placed to dynamically include the width into our cell value.
  8. The last text in our cell is "is".
  9. Finally, we need to append the PRODUCT formula, you need to add a & at the end.
  10. Then write the formula PRODUCT(A2,B2).

Follow the above steps and you can form any dynamic content inside the cell, it’s that simple. Just remember one golden rule. All dynamic need to be connected using & characters without double quotes, and all static ones need to be placed within double quotes.

如何在 Microsoft Excel 中的单元格内添加文本和公式

Step 6: If you press the Enter key, you can see that all values ​​are dynamically replaced, you can also Drag the same format to all cells in the same column as described in step 3.

如何在 Microsoft Excel 中的单元格内添加文本和公式

The above is the detailed content of How to enter text and formulas into cells in Microsoft Excel. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yundongfang.com. If there is any infringement, please contact admin@php.cn delete