473,387 Members | 1,483 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

remove apostrophe?

I have imported data from another program, and I run into this problem where an apostrophe got added to the beginning of each Cell; because of this I can't format the cells. Anyone has a solution? I am using Excel 2003 Thanks in advance.
Jun 19 '08 #1
12 12760
missinglinq
3,532 Expert 2GB
I'm confused by your post, in that this is a forum for Access questions. Are you importing data from Excel 2003 into Access?

You also don't say where you're trying to do this, but in Access/VBA the general way to strip a leading apostrophe would be
Expand|Select|Wrap|Line Numbers
  1. If Left(Me.OriginalCell, 1) = "'" Then
  2.   Me.OriginalCell = Right(Me.OriginalCell, Len(Me.OriginalCell) - 1)
  3. End If
  4.  
Linq ;0)>
Jun 19 '08 #2
Stewart Ross
2,545 Expert Mod 2GB
Hi. Linq's solution is valid for VBA and Access. Assuming that this is really an Excel question, the apostrophe is indicating that the values were exported as text (in Excel the use of a leading apostrophe forces interpretation of values as text strings). The apostrophe is not actually treated as part of the string, so removing it is not as straightforward as it could be.

The simplest solution in Excel itself is to leave these values as they are, add a blank column immediately after them and replicate the following value conversion from the top cell down the column:
Expand|Select|Wrap|Line Numbers
  1. =Value(CellRef)
where CellRef is the appropriate cell reference for the text string value (A1, C4 or whatever). After doing so, select the new column, use Copy and Paste Special, Values to paste the values into the cells (overwriting the =value() formulas). You can then delete the original (text-exported) columns.

If this process has to be done frequently you can always record the steps as an Excel macro to automate the conversion, or program the conversion directly in VBA.

-Stewart
Jun 20 '08 #3
NeoPa
32,556 Expert Mod 16PB
This is actually a lot more complicated than it appears (although, if you can afford to lose any formatting that might be associated with the cells, then Stewart's solution will work well for you). The problem is that the apostrophe is treated in a special way by Excel in that it works like formatting but is stored in the cell in such a way that only the data is seen (Check the .Value, .Text & .Formula properties). The only place I can find the apostrophe is in the cell editing area when the cell is active.

Assuming Stewart's solution is not adequate to your needs, try the following slightly more fiddly one instead which will keep all formatting etc from the original cells (column).
  1. Copy the required column (Select at top and Ctrl-C).
  2. Insert into next column position (Select next column and, using right-click, choose Insert Copied Cells).
  3. Select all cells that you want to change.
  4. Type in A (or any basic text) followed by Ctrl-Enter to put this into each selected cell. This clears the cell from wanting to insert the apostrophe.
  5. Type in "=CellRef" (Hit "=" key then right-arrow key) and then Ctrl-Enter to enter the modified version of the formula into each selected cell.
  6. Copy these cells again (Ctrl-C).
  7. Paste / Special / Values (Alt-E,S,V,Enter) to put the changed values back into the selected cells.
  8. Lastly, remember to delete the column that was added to leave the data as it was before, except for having removed the apostrophes.
Jun 20 '08 #4
I am sorry for not being clear. The data was imported from one excel sheet to another. the apos was used for an invoice number column to show the zeros. I was able to solve it.
Thank you all for your help.
Jun 20 '08 #5
NeoPa
32,556 Expert Mod 16PB
It irritated me that I couldn't find a property that was different in the cell when the data had an apostrophe prefix, so I dug further and found the .PrefixCharacter property, which contains an apostrophe when used. Unfortunately this is a read-only property so cannot simply be reset to strip any from a selection of cells :(
Jun 20 '08 #6
Annalyzer
122 100+
I think I can help with this one.

On the menu, select Tools then Options. Click on the Error Checking tab. Under Settings, make sure that Enable background error checking is checked and under Rules make sure that Number stored as text is checked. Close the dialog box.

On the menu, select Edit then GoTo and click the Special... button. Select the Constants radio button, then uncheck Numbers, Logicals, and Errors (leave Text checked). This will highlight all the cells in the worksheet that contain text (don't worry, we're not going to hurt the ones that are supposed to be text).

Error checking will now indicate the errors with an exclamation point. Click on the exclamation point (if there are several, just click one of them) and click Convert to Number.

This will convert all the cells with the apostrophe to numbers, but will not affect the cells which actually have text.
Jun 23 '08 #7
Stewart Ross
2,545 Expert Mod 2GB
Well done, Annalyser - I wouldn't have dreamt of using the error checking to find such values, and doing so reveals a few useful features that for me were so well-hidden that I have never used them (Goto, Special for one...). Great stuff!

-Stewart
Jun 23 '08 #8
NeoPa
32,556 Expert Mod 16PB
Sounds good Analyser.

Do you have a version number for Excel though, as I can't find this in Excel 2000 :(
Jun 23 '08 #9
Annalyzer
122 100+
I'm using Excel 2003. I didn't know about it when I had Excel 2000, so I couldn't say for sure if it was available or not.
Jun 23 '08 #10
NeoPa
32,556 Expert Mod 16PB
That's fine. I'll check it out on 2003 at home.

Thanks :)
Jun 23 '08 #11
Annalyzer
122 100+
Glad I could help. I really love Excel. If there is ever an Excel forum added to this site, you can bet I'll be found hanging out there often. =)
Jun 23 '08 #12
NeoPa
32,556 Expert Mod 16PB
That's good to hear :) I quite like Excel myself in fact.

In the mean time, Office VBA is covered in here where necessary and an odd Excel question finds itself in here from time to time. We just don't guarantee to answer it as most of our experts specialise in Access.
Jun 24 '08 #13

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Michael Sterling | last post by:
i'm using delphi 7 and have a query in which i'm trying to find names that have an apostrophe in them, i.e. "o'mally". my problem is that when i write my select statement i can't get the quotes...
13
by: Richard Hollenbeck | last post by:
To prevent future apostrophe bugs and errors, isn't it just simpler to forbid an apostrophe from being entered into a text field? For example, couldn't "Alice's Restaurant" be changed to "Alices...
1
by: congngo | last post by:
Hi all Every time I export a table into an excel spreadsheet. It has a leading apostrophe on every cells. This drive me nut. I have to do a work around by export table into a txt file than...
1
by: spacehopper_man | last post by:
hi - I am having "apostrophe in sql" problems ;) I am executing a stored procedure on SQL Server - and passing in a string parameter. the string has a single apostrophe in it. the call...
1
by: Rose | last post by:
Hi all, I'm trying to create a clickable link, but the pesky apostrophe is preventing the link from getting displayed properly. I'm displaying the contents of a folder (with contains the...
2
by: Tom | last post by:
Hi, I have some kind of problems with an apostrophe character ('). I would like to select from DataTable DataRow containing value horses' (with an apostrophe on the end). But when I do it in an...
9
by: Smiley | last post by:
Hi, Can someone tell me how to remove aspostophe (') from user input. I don't want to give any error message. Just want to remove or change it to "" or null, such input when it appear anywhere...
9
by: Thomas 'PointedEars' Lahn | last post by:
Jukka K. Korpela wrote: IBTD. For example, in English it is customary (and AIUI expected) to use the character that ’ represents should be used to delimit a quotation within direct speech...
4
by: Razzbar | last post by:
I'm working on a bookmarklet that grabs information from a page and submits it to a server. Yet another social bookmarking application. I'm having trouble with page titles that include an...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.