ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Quote Marks Through VBA (https://www.excelbanter.com/excel-discussion-misc-queries/119050-quote-marks-through-vba.html)

[email protected]

Quote Marks Through VBA
 
Very simple question, but I can't figure it out:

I want to make a formula in a cell through VBA, but I want the formula
to have a word in it (which needs to be in quotes). That is, I want
the formula to read:

=IF(Sheet2!G6="Maturity",1,2)

How can I get the Maturity part surrounded by quotes?

Thanks!

Brett


Don Guillett

Quote Marks Through VBA
 
You did it right if the ref cell does have maturity in it. Maybe leading or
trailing space?
=IF(TRIM(F1)="maturity",1,2)

--
Don Guillett
SalesAid Software

wrote in message
oups.com...
Very simple question, but I can't figure it out:

I want to make a formula in a cell through VBA, but I want the formula
to have a word in it (which needs to be in quotes). That is, I want
the formula to read:

=IF(Sheet2!G6="Maturity",1,2)

How can I get the Maturity part surrounded by quotes?

Thanks!

Brett




Gary''s Student

Quote Marks Through VBA
 
I put them in explicitly thru chr():


Sub brett()
Dim s As String
s = "=IF(Sheet2!G6=" & Chr(34) & "Maturity" & Chr(34) & ",1,2)"
Cells(1, 1).Formula = s
End Sub

--
Gary's Student


" wrote:

Very simple question, but I can't figure it out:

I want to make a formula in a cell through VBA, but I want the formula
to have a word in it (which needs to be in quotes). That is, I want
the formula to read:

=IF(Sheet2!G6="Maturity",1,2)

How can I get the Maturity part surrounded by quotes?

Thanks!

Brett



[email protected]

Quote Marks Through VBA
 
Thanks! That works - is there a place I can see all the character code
numbers?

Gary''s Student wrote:
I put them in explicitly thru chr():


Sub brett()
Dim s As String
s = "=IF(Sheet2!G6=" & Chr(34) & "Maturity" & Chr(34) & ",1,2)"
Cells(1, 1).Formula = s
End Sub

--
Gary's Student


" wrote:

Very simple question, but I can't figure it out:

I want to make a formula in a cell through VBA, but I want the formula
to have a word in it (which needs to be in quotes). That is, I want
the formula to read:

=IF(Sheet2!G6="Maturity",1,2)

How can I get the Maturity part surrounded by quotes?

Thanks!

Brett




Gary''s Student

Quote Marks Through VBA
 
Fill column A with all the keyboard characters:

A
B
C
..
..
..

both upper and lower case and the keys like as well


Then in B1 enter:
=CODE(A1) and copy down.
--
Gary's Student


" wrote:

Thanks! That works - is there a place I can see all the character code
numbers?

Gary''s Student wrote:
I put them in explicitly thru chr():


Sub brett()
Dim s As String
s = "=IF(Sheet2!G6=" & Chr(34) & "Maturity" & Chr(34) & ",1,2)"
Cells(1, 1).Formula = s
End Sub

--
Gary's Student


" wrote:

Very simple question, but I can't figure it out:

I want to make a formula in a cell through VBA, but I want the formula
to have a word in it (which needs to be in quotes). That is, I want
the formula to read:

=IF(Sheet2!G6="Maturity",1,2)

How can I get the Maturity part surrounded by quotes?

Thanks!

Brett





Gizmo63

Quote Marks Through VBA
 
By far the simplest way is to double up the quotes, so the code looks like
this:

Range([range to insert formula]) = "=IF(Sheet2!G6=""Maturity"",1,2)"

HTH

Giz

" wrote:

Very simple question, but I can't figure it out:

I want to make a formula in a cell through VBA, but I want the formula
to have a word in it (which needs to be in quotes). That is, I want
the formula to read:

=IF(Sheet2!G6="Maturity",1,2)

How can I get the Maturity part surrounded by quotes?

Thanks!

Brett



Bob Phillips

Quote Marks Through VBA
 
=IF(Sheet2!G6=""Maturity"",1,2)

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

wrote in message
oups.com...
Very simple question, but I can't figure it out:

I want to make a formula in a cell through VBA, but I want the formula
to have a word in it (which needs to be in quotes). That is, I want
the formula to read:

=IF(Sheet2!G6="Maturity",1,2)

How can I get the Maturity part surrounded by quotes?

Thanks!

Brett




Don Guillett

Quote Marks Through VBA
 
oops. didn't notice the vba part

--
Don Guillett
SalesAid Software

"Don Guillett" wrote in message
...
You did it right if the ref cell does have maturity in it. Maybe leading
or trailing space?
=IF(TRIM(F1)="maturity",1,2)

--
Don Guillett
SalesAid Software

wrote in message
oups.com...
Very simple question, but I can't figure it out:

I want to make a formula in a cell through VBA, but I want the formula
to have a word in it (which needs to be in quotes). That is, I want
the formula to read:

=IF(Sheet2!G6="Maturity",1,2)

How can I get the Maturity part surrounded by quotes?

Thanks!

Brett






Dana DeLouis

Quote Marks Through VBA
 
Just an idea. Some like to use a custom function for the quotes.
A function named "Q" seems to be popular. (another might QQ for Double
quotes)

[A1] = "=IF(Sheet2!G6=" & Q("Maturity") & ",1,2)"

Sometimes this can help if the equation is complicated.
--
HTH :)
Dana DeLouis
Windows XP & Office 2003


wrote in message
ps.com...
Thanks! That works - is there a place I can see all the character code
numbers?

Gary''s Student wrote:
I put them in explicitly thru chr():


Sub brett()
Dim s As String
s = "=IF(Sheet2!G6=" & Chr(34) & "Maturity" & Chr(34) & ",1,2)"
Cells(1, 1).Formula = s
End Sub

--
Gary's Student


" wrote:

Very simple question, but I can't figure it out:

I want to make a formula in a cell through VBA, but I want the formula
to have a word in it (which needs to be in quotes). That is, I want
the formula to read:

=IF(Sheet2!G6="Maturity",1,2)

How can I get the Maturity part surrounded by quotes?

Thanks!

Brett






[email protected]

Quote Marks Through VBA
 
Doubling quotes is not sufficient. You need to triple them. Or am I
missing something?

=IF(Sheet2!G6="""Maturity""",1,2)

The way I see it is this. The 1st quote just begins the quote
sequence. The second quote would normally end it, but since it is
followed by a quote, it is interpreted as a "hard" quote instead. Then
the fourth quote would normally end it, but it too is followed by a
quote so it is made hard, and the then 6th quote just ends the whole
shebang.

Dom



Bob Phillips wrote:
=IF(Sheet2!G6=""Maturity"",1,2)

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

wrote in message
oups.com...
Very simple question, but I can't figure it out:

I want to make a formula in a cell through VBA, but I want the formula
to have a word in it (which needs to be in quotes). That is, I want
the formula to read:

=IF(Sheet2!G6="Maturity",1,2)

How can I get the Maturity part surrounded by quotes?

Thanks!

Brett



kassie

Quote Marks Through VBA
 
You are right about the triple part, but not about the placement. The first
set of quotes include the entire formula "=IF(Sheet2!G6=""Maturity"",1,2"

" wrote:

Doubling quotes is not sufficient. You need to triple them. Or am I
missing something?

=IF(Sheet2!G6="""Maturity""",1,2)

The way I see it is this. The 1st quote just begins the quote
sequence. The second quote would normally end it, but since it is
followed by a quote, it is interpreted as a "hard" quote instead. Then
the fourth quote would normally end it, but it too is followed by a
quote so it is made hard, and the then 6th quote just ends the whole
shebang.

Dom



Bob Phillips wrote:
=IF(Sheet2!G6=""Maturity"",1,2)

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

wrote in message
oups.com...
Very simple question, but I can't figure it out:

I want to make a formula in a cell through VBA, but I want the formula
to have a word in it (which needs to be in quotes). That is, I want
the formula to read:

=IF(Sheet2!G6="Maturity",1,2)

How can I get the Maturity part surrounded by quotes?

Thanks!

Brett




Bob Phillips

Quote Marks Through VBA
 
I responded in the style of the question, therefore triple is not needed, it
will either be placed into a variable, in which case it will need enclosing
within quotation marks, or it will be a property value in-line, in which
case it would also be enclosed within quotation marks.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

wrote in message
oups.com...
Doubling quotes is not sufficient. You need to triple them. Or am I
missing something?

=IF(Sheet2!G6="""Maturity""",1,2)

The way I see it is this. The 1st quote just begins the quote
sequence. The second quote would normally end it, but since it is
followed by a quote, it is interpreted as a "hard" quote instead. Then
the fourth quote would normally end it, but it too is followed by a
quote so it is made hard, and the then 6th quote just ends the whole
shebang.

Dom



Bob Phillips wrote:
=IF(Sheet2!G6=""Maturity"",1,2)

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

wrote in message
oups.com...
Very simple question, but I can't figure it out:

I want to make a formula in a cell through VBA, but I want the formula
to have a word in it (which needs to be in quotes). That is, I want
the formula to read:

=IF(Sheet2!G6="Maturity",1,2)

How can I get the Maturity part surrounded by quotes?

Thanks!

Brett





Gord Dibben

Quote Marks Through VBA
 
In A1 enter =CHAR(ROW())

Copy down to row 256 to see the associated characters.


Gord Dibben MS Excel MVP

On 16 Nov 2006 06:25:25 -0800, wrote:

Thanks! That works - is there a place I can see all the character code
numbers?




All times are GMT +1. The time now is 10:21 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com