Products Log in Sign up
Ask Question
Using " as a character in a
statement [duplicate]
Asked 4 years, 4 months ago
Modified 4 years, 4 months ago Viewed 335 times
This question already has answers
here:
-1
How do I put double quotes in a string
in vba? (4 answers)
Closed 4 years ago.
1
Hi there I am trying to use " as a
character in my code, but VBA always
auto corrects it as excess characters
(like if I try """ ). I tried to use the
Char(34) character code but it still
doesn't work. I want to loop through
cells and search for values within the
cell such as " ActiveCell.Value " but
the code doesn't recognize " as a
character. Here is the code:
Sub zero()
Do Until IsEmpty(ActiveCell.Value)
Shell ("C:\Program Files (x86)\Google
ActiveCell.Offset(1).Select
Loop
End Sub
vba excel
Share Follow
asked Apr 24, 2018 at 15:32
Rhyfelwr
269 1 5 19
5 You need to double up the quotes to
escape them in VBA, so
doubleQuotes = """" is
assigning one double-quote
character, which is indeed
Chr(34) . "but it doesn't work"
isn't a useful problem description we
can work with. How is it failing?
– Mathieu Guindon Apr 24, 2018 at
15:36
Could you tell us what
Debug.Print "C:\Program
Files
(x86)\Google\Chrome\Applicat
ion\Chrome.exe -url
https://www.google.co.uk/sea
rch?q=" & Chr(34) &
ActiveCell.Value & Chr(34)
returns? – TomJohnRiddle Apr 24,
2018 at 15:37
This code works 100% fine for me.
Are you getting an error, incorrect
results? What's the problem exactly?
– JNevill Apr 24, 2018 at 15:50
Add a comment
Sorted by:
1 Answer
Highest score (default)
You need to use four rabbits ears within
a VBA string for a single quotation
4 character.
For this reason I define
Public Const vbQuote As String = """"
and use in this way
& vbQuote & ActiveCell.Value & vbQuote
Share Follow
answered Apr 24, 2018 at 15:43
Bathsheba
229k 33 352 472
Thank you this method worked, I was
actually asked by a colleague who
doesn't have a SO account to post
this that's why I couldn't define
clearly what the problem was.
– Rhyfelwr Apr 25, 2018 at 8:36
Add a comment
Not the answer you're looking for? Browse other
questions tagged vba excel or ask your own
question.
The Overflow Blog
The many problems with implementing Single
Sign-On
Hackathons and free pizza: All about Stack
Overflow’s new Student Ambassador...
Featured on Meta
Announcing the Stack Overflow Student
Ambassador Program
Google Analytics 4 (GA4) upgrade
The [option] tag is being burninated
Should I explain other people's code-only
answers?
Reviewer overboard! Or a request to improve
the onboarding guidance for new...
Linked
150 How do I put double quotes in a string in vba?
Related
46 How to loop in excel without VBA or macros?
616 How to avoid using Select in Excel VBA
0 VBA If Statement and For Loop moving to the
cell below
1 How to Make Cells "Blank," not "Empty" in VBA
0 If statement with a variable without a loop
Hot Network Questions
If Hans Niemann is cheating, how?
What determines which military uniform is worn at
which event by members of the Royal Family
A Riddle In Between
Do these NY old dumb laws actually exist?
Is there a reasonable "text-to-speech" solution for
math papers?
Lady Penelope's birth date and wikipedia
how to find a file that is NOT executable
ANSI terminal color behaves strangely
Does there exist a second degree curve with exactly
two solutions?
In what manner "prescribed by law" can a soldier be
permitted to stay in a privately owned home without
violating the Third Amendment?
Does "SHA-256/192" use different initial values from
SHA-256?
Which of those parameters is default in DBCC
SHRINKFILE command?
Simplify with given equality
What value is there in requiring students to answer
word problems in complete sentences?
In novel writing, should I change the referred name of
a character when he revealed his name to the
protagonist?
Alternative interpretation of multiple regression
coefficients?
Why do high rated players still take so much time to
calculate a pawn endgame position close to a game
that they (likely) had before?
How to solve this group of equations?
Why are the 767’s main landing gear spaced
considerably farther apart than airplanes of a
comparable size?
How to diplomatically tell coworker to back off?
Can an interviewer ask me why I'm no longer with my
past employer?
Can a person go to the court if she signed a contract
not to go to court?
What is the best way to plan an inland sailing trip?
Pack of dogs - best response to owner?
STACK OVERFLOW
Questions Help
PRODUCTS
Teams Advertising Collectives Talent
COMPANY
About Press Work Here Legal Privacy Policy
Terms of Service Contact Us Cookie Settings
Cookie Policy
STACK EXCHANGE NETWORK
Your privacy
Technology Culture & recreation Life & arts Science
Professional
By clicking “Accept
Businessall cookies”,
API Datayou agree Stack Exchange
can store cookies on your device and disclose information
in accordance with our Cookie Policy.
Blog Facebook Twitter LinkedIn Instagram
Accept all cookies Customize settings
Site design / logo © 2022 Stack Exchange Inc; user contributions
licensed under CC BY-SA. rev 2022.9.13.42973