+ Reply to Thread
Results 1 to 10 of 10

Quotation mark?

Hybrid View

Rick_Stanich Quotation mark? 05-08-2008, 05:41 PM
shg Try If... 05-08-2008, 05:44 PM
Andy Pope Don't forget to specify the... 05-08-2008, 05:50 PM
Rick_Stanich Oh hell, that was too easy! ... 05-08-2008, 05:50 PM
Rick_Stanich Excel 2007 simply will not... 05-08-2008, 06:38 PM
shg Both the VBA and worksheet... 05-08-2008, 06:41 PM
Andy Pope That will teach me to test... 05-08-2008, 06:46 PM
  1. #1
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,177

    Quotation mark?

    How do you find if the last character in a string is a quotation mark?
    If Right(Range("A1").Value = """ Then
    If I enter this as above it will not work. I have a unique case that many cells will have a quotation mark as the last character, I can not prevent this but I do need to capture the cell address and do some code.

    Any help is appreociated!
    Regards

    Rick
    Win10, Office 365

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    Try
    If Right(Range("A1").Value) = Chr(34) Then
    ' or
    If Right(Range("A1").Value) = """ Then
    Last edited by shg; 05-08-2008 at 05:46 PM.

  3. #3
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,482
    Don't forget to specify the number of characters

    
    If Right(Range("A1").Value,1) = """ Then

  4. #4
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,177
    Oh hell, that was too easy!

    Thank you!

  5. #5
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,177
    Excel 2007 simply will not except this format
    If Right(Range("A1").Value,1) = """ The
    But it does when formatted as
    If Right(Range("A1").Value) = Chr(34) Then
    So, how do I replace the quotation mark, this will not work.
    Replace(Range("A1").Value, """ , "")
    'or
    Replace(Range("A1").Value, Chr(34) , "")
    I have to find the quotation mark, place the text value of the cell in a variable, remove the quotation mark and concatenate with another cell. I have it all less removing that darn quotation mark.

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    Don't forget to specify the number of characters
    Both the VBA and worksheet versions default to 1

    So, how do I replace the quotation mark
    You mean remove a trailing quote if there is one? Maybe
    with range("a1")
        someStr = iif(right(.value) = chr(34), left(.value, len(.value) - 1), .value)
    end with
    Last edited by shg; 05-08-2008 at 06:48 PM.

  7. #7
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,482
    That will teach me to test code in the immediate window only!

    You need 4 quotes in any version.
    
        If Right(Range("A1").Value, 1) = """" Then
    The argument is optional in worksheet function but not VBA

  8. #8
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,177
    Thank you, why can't help just state that?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1