Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 48
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,124
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default 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


  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 48
Default 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



  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default 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






  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 43
Default 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


  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,593
Default 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



  #9   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 947
Default 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





  #10   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 46
Default 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




  #11   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 268
Default 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



  #12   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,593
Default 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




  #13   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default 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?


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
slash marks in dates childothe1980s Excel Discussion (Misc queries) 2 July 25th 06 02:24 AM
Formula - Marks in Group Zainuddin Zakaria Excel Discussion (Misc queries) 1 April 20th 06 10:54 PM
Pease help with a formula to select 7 best marks out of 12 perfection Excel Discussion (Misc queries) 2 April 14th 06 07:12 AM
how can i trace position in marks sheet adeel afzal via OfficeKB.com Excel Worksheet Functions 3 July 31st 05 08:39 PM
Y-axis tick marks in middle of chart? Ed Charts and Charting in Excel 6 May 26th 05 01:16 PM


All times are GMT +1. The time now is 02:53 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"