sam0406
sam0406

Reputation: 25

Declare a variable with quotes around it

At the moment I want to declare a variable and give it the value "C1" (Including the quotes)

In the same way that that I can get C:5 by doing

DeclaredVariable = "C" & ":" & "5"

I have tried something like

AfterRange = """ & "C1" & """

but this give me the error "Expected: end of statement" and highlights the part with C1 on it

How could I solve this issue?

Upvotes: 0

Views: 63

Answers (2)

FaneDuru
FaneDuru

Reputation: 42236

Each " must be doubled by another one. Inside the string use "" and at the string margins use """ (an extra one quote). If you need ONLY double quotes, you must use """". There are two margins...

Beside that, Chr(34) means also a quote.

Upvotes: 0

Daghan
Daghan

Reputation: 769

Both of these give the output "C1". But you should consider looking into ranges

AfterRange = Chr(34) & "C1" & Chr(34)

AfterRange = """C1"""

Upvotes: 2

Related Questions