?
Solved

Explanation of how to include text quotation marks in Excel formulas

Posted on 2013-06-01
4
Medium Priority
?
278 Views
Last Modified: 2013-06-17
Hello,

Can someone provide an explanation for how to correctly insert a text quotation mark (qm) into an Excel formula? Obviously there needs to be a way to identify it as not indicating the beginning or end of text included in the formula but part of the text itself.

I've seen solutions here and elsewhere that include four qm's in a row ("""") but I've never understood why. Thus, when I'm confronted with something new, I have a difficult time getting it right.

I can think of only three positions a qm can occupy: at the beginning, somewhere in the middle & at the end of text to be included. For example, suppose you've got data in three columns (B, C & D) as shown here:
Fig. 1And suppose you want to be able to modify the following sentence in three places (underlined) using references to the three columns:

    "What's the plan?" I asked. Jack replied, "I will see Jane in 3 days."

Now, if you will allow me to replace the opening qm's with forward slashes (/) and the closing qm's with reverse slashes (\), it would look like this:

    /What's the plan?\ I asked. Jack replied, /I will see Jane in 3 days.\

In that case, the formula would be as follows:

="/What's the plan?\ I asked. "&B4&" replied, /I will see "&C4&" in "&D4&" days.\"

or, segmented:

="/What's the plan?\ I asked. "&
        B4&
  " replied, /I will see "&
        C4&
  " in "&
        D4&
  " days.\"

Hopefully all that is not just confusing things but if it makes sense, could you show me the correct way to write the formula and do it in two ways:  

    • #1 as it would appear with qm's where they should be (i.e. replacing the slashes),

    • #2 as it would appear with slashes still present so it's easy to see which of the qm's in #1 are part of the text

— and also include any comments you can that explain why the #1 solution is correct.

Thanks
0
Comment
Question by:Steve_Brady
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 25

Accepted Solution

by:
clockwatcher earned 1000 total points
ID: 39213935
Two consecutive double quote marks within a string expression are an example of an escaped quote.  They're how you represent a double quote within a string.  

So in your example, where you've got your / and \ to indicate a double quote mark:

="/What's the plan?\ I asked. "&
        B4&
  " replied, /I will see "&
        C4&
  " in "&
        D4&
  " days.\"

All you need to do is simply replace every instance of your / or a \ with two consecutive double quotes and you have your string expression:

="""What's the plan?"" I asked. "&
        B4&
  " replied, ""I will see "&
        C4&
  " in "&
        D4&
  " days."""

It's as simple as that.
0
 
LVL 14

Assisted Solution

by:Faustulus
Faustulus earned 600 total points
ID: 39213947
I know that it is as simple as that, but it isn't clear. That is why I prefer to use a longer but - to me - much clearer method:-
=CHAR(34) & "What is the plan?" & CHAR(34) & " I asked. " & B4 & " replied, " & CHAR(34) & "I will see " & C4 & " in " & D4 & " days." & CHAR(34)

When constructing this sentences you can first create it without the qm's:
=CONCATENATE("What is the plan?"," I asked. ",B4," replied, ","I will see ",C4," in ",D4," days.")

Then, just add the qm's where you need them:-
=CONCATENATE(CHAR(34),"What is the plan?",CHAR(34)," I asked. ",B4," replied, ",CHAR(34),"I will see ",C4," in ",D4," days.",CHAR(34))
0
 
LVL 24

Assisted Solution

by:Steve
Steve earned 400 total points
ID: 39214145
you could also use Substitute for the three values to form the sentence which would be a little easier to read

with "What's the plan?" I asked. Male replied, "I will see Female in #Days days." in cell A1 and the table you could use...
=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE($A$1,$B$2,B3),$C$2,C3),$D$2,D3)
Substitute.xlsx
0
 

Author Closing Comment

by:Steve_Brady
ID: 39254676
Thanks for the great responses. They are very helpful.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question