+ Reply to Thread
Results 1 to 9 of 9

Why Apostrophes Don't Appear in Cell??

  1. #1
    Registered User
    Join Date
    03-31-2009
    Location
    Auburn Alabama
    MS-Off Ver
    Microsoft Office Excel 2007 (Windows)
    Posts
    99

    Why Apostrophes Don't Appear in Cell??

    Hello,

    My question is about reading an Apostrophe/Single Quote to a cell.

    My program reads a text file a single character at a time. And many lines of the text I'm reading begin with a single quote.

    Unlike double quotes and other characters, single quotes aren't showing up in cells when they are read in first. They show up only in the function box. This is a huge problem for my program.

    The following code produces the correct results:
    Please Login or Register  to view this content.
    This correctly writes the letter A to the first cell.

    However, the following code:
    Please Login or Register  to view this content.
    ... Doesn't write the single quote to the cell when it's the first character in the cell. It only writes the single quote to the function box. This is a huge problem because when i try to append the next character to the value of the cell holding the single quote, the single quote is entirely omitted and it never appears in the result.

    Is there a workaround for this? How can I write a single quote to a cell and have it appear there when the next character is appended to it?

    Thanks for any and all help.
    Last edited by CrazyFileMaker; 04-28-2009 at 12:11 AM.

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Why Apostrophes Don't Appear in Cell??

    Not entirely sure why/what you're doing but you may find that you're better off adding Chr(39) twice over at the end of processing all other chrs... so once you've processed the string do a test of the left most char and if it's chr39 repeat it twice, eg:

    Please Login or Register  to view this content.
    If you're looking to strip certain chars in a string you may find regular expressions a better / faster alternative to your current method... not for the feint hearted mind -- I'm still getting an idea of the basics myself but you'll find NBVC etc have posted quite a few examples - for more info see: http://www.regular-expressions.info/

  3. #3
    Valued Forum Contributor
    Join Date
    06-16-2006
    Location
    Sydney, Australia
    MS-Off Ver
    2013 64bit
    Posts
    1,394

    Re: Why Apostrophes Don't Appear in Cell??

    the single apostrophe is short hand for text in a cell. Just like the + or = is the shorthand for a formula. That is why you have a problem. If you need to put the apostrophe in, use the formula =char(39)

  4. #4
    Registered User
    Join Date
    03-31-2009
    Location
    Auburn Alabama
    MS-Off Ver
    Microsoft Office Excel 2007 (Windows)
    Posts
    99

    Re: Why Apostrophes Don't Appear in Cell??

    Thanks Donkey. That's a good idea.

    Would you or someone tell me, are there other characters that don't appear in cells when written to them first? I want to account for other characters that might be of equal surprise.

  5. #5
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Why Apostrophes Don't Appear in Cell??

    Not that I can think of - other than 0 of course if the entire string is numeric and the cell is not formatted to Text... that's not to say there aren't any ...

  6. #6
    Valued Forum Contributor
    Join Date
    06-16-2006
    Location
    Sydney, Australia
    MS-Off Ver
    2013 64bit
    Posts
    1,394

    Re: Why Apostrophes Don't Appear in Cell??

    Quote Originally Posted by CrazyFileMaker View Post
    Would you or someone tell me, are there other characters that don't appear in cells when written to them first?
    see my post above + and = if they are first and don't form working formulae, you will get an error. unless you import it as text

  7. #7
    Registered User
    Join Date
    03-31-2009
    Location
    Auburn Alabama
    MS-Off Ver
    Microsoft Office Excel 2007 (Windows)
    Posts
    99

    Re: Why Apostrophes Don't Appear in Cell??

    Thanks Donkey and MallyCat. That's helpful.

    MallyCat. I see what you're saying about =Char(39). If I type =Char(39) into a cell, is there anyway to append other strings to that value? When I enter letters after that, like "=Char(39) Apple" i get the message: "The formula you typed contains an error"

    If i could somehow append other letters to that value, that would work for sure. Is that possible?

  8. #8
    Valued Forum Contributor
    Join Date
    06-16-2006
    Location
    Sydney, Australia
    MS-Off Ver
    2013 64bit
    Posts
    1,394

    Re: Why Apostrophes Don't Appear in Cell??

    There is always a way. It just depends on how easy the solution is. This one is easy - use the ampersand character like this

    =char(39) & " Apple"

    leaving spaces inside the quotes where you need them
    Last edited by Mallycat; 04-23-2009 at 03:02 AM. Reason: clarity

  9. #9
    Registered User
    Join Date
    03-31-2009
    Location
    Auburn Alabama
    MS-Off Ver
    Microsoft Office Excel 2007 (Windows)
    Posts
    99

    Re: Why Apostrophes Don't Appear in Cell??

    That worked! Thank you!!!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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