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

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
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,224,823
Messages
6,181,171
Members
453,021
Latest member
Justyna P

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