Insert Cell Values into IF Formula Text in Excel
Question details
Combine numbers from cells with text returned by an IF formula for use in documents or mail merges.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- Create a conditional text passage that includes a share count and a dollar amount from worksheet cells.
- Observed behavior
- When the condition is met, the formula should return the text with the cell values inserted; otherwise, it should return an empty string.
Identify the condition cell and the cells containing the values you want to insert. In the example below, D1 contains the condition, C2 contains the share count, and P2 contains the dollar amount.
Use an ampersand to combine IF formula text and cell values
Use this approach to insert cell values into a text passage only when the IF condition is met.
In Excel, click an empty cell where you want the completed text to appear.
Enter =IF(D1="Applicable","and "&C2&" restricted common shares of Company Ltd. (as traded on the New York Stock Exchange under the symbol CPY, the Company Stock), calculated by dividing $"&P2&" by the Volume Weighted Average Price of the Company Stock, payable at closing.","") and press Enter.
In the formula bar, replace C2 with TEXT(C2,"#,##0") for a whole-number share count, or replace P2 with TEXT(P2,"#,##0.00") to show two decimal places after the dollar sign.
Enter Applicable in D1 and verify that the output includes the values from C2 and P2. Change D1 to another value to confirm that the formula returns an empty string.

Build conditional text with WPS Spreadsheets
Use IF, ampersands, and TEXT in WPS Spreadsheets to combine worksheet values with a conditional text passage.
- 1. Open the workbook: Open WPS Spreadsheets and use Open to select your Excel workbook.
- 2. Select an output cell: Click an empty cell where the conditional passage should appear.
- 3. Enter the formula: Type =IF(D1="Applicable","and "&C2&" shares, calculated by dividing $"&TEXT(P2,"#,##0.00"),"") and press Enter. Adjust the text and cell references for your worksheet.
- 4. Check and save: Set D1 to Applicable, check the result, and use File > Save to save the workbook.

Frequently Asked Questions
How do I add a space between text and a cell value?
Include the space inside the quoted text. For example, ="Shares: "&C2 adds a space after the colon before inserting C2.
Why did my currency formatting disappear in the combined text?
Concatenation uses the underlying value rather than necessarily preserving the cell's display format. Use a formula such as ="$"&TEXT(P2,"#,##0.00") to show two decimal places.
How do I include quotation marks inside the returned text?
Double each quotation mark inside a formula string. For example, ="the ""Company Stock""" returns the text the "Company Stock".
Can I use the formula result in a Word mail merge?
Yes. Save the Excel workbook with a header for the formula column, then in Word select Mailings > Select Recipients > Use an Existing List and choose the workbook. Insert the column as a merge field and preview the results.




