Display single quotation mark as text using VBA

csilabgirl

Active Member
Joined
Aug 14, 2009
Messages
359
Using excel 2010

I have the following line of code. Range("D13") = "(6) 1 1/4" Screws"

I want range D13 to say the following:

(6) 1 1/4" Screws

I want the single quotation mark after 1 1/4 to be displayed since it's denoting inches. But I keep getting a debug. What do I need to add to this to get that to display? Thank you.
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
First of all, that is a double quotation mark, not a single quotation mark.

The way to do it in VBA (one of them), is to double up on the double quotation marks:

Code:
Range("D13") = "(6) 1 1/4"" Screws"

The first " is what's called an 'escape character', that lets VBA know it is an exception to the rule. Because VBA normally interprets " as a beginning or end of a string of text, you have to use the escape character to let it know that you literally want a double quote character.

Does that help / solve your issue?
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,231
Messages
6,170,885
Members
452,364
Latest member
springate

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top