Now this is a weird one
We have a project where we are reading some data from an Excel spreadsheet. Obviously this data has to be in a certain format. Some of the fields consists of numbers, but should be treated as text.
To stop Excel from being "smart" and change the cell types, I have set the format in the respective cells to 'text'.
Now here is the problem: some of the numbers we're pasting have spacing between the digits. When we remove the white spaces, Excel change the cell format to 'standard' and turn the text into the 2.42805E+11 format.
BUT: this only happens when the text is copied from some sources. If a paste a number copied from a textbox, everything turn out fine when we edit the spaces. If we copy the exact same number from a web page, Excel change cell format.
I thought copy-paste would be copy-paste, but obviously some formating or something gets along on the ride.
Does anyone know what causes this, or know have to get Excel to stop being "smart" with the formating?
EDIT: I found a somewhat peculiar solution to this. I recorded a macro that uses the 'Paste Special' function with text as parameter, and overrided ctrl-v with it (in that particular spreadsheet). Works like a charm! Feels a bit "hacky", though. Can anyone think of a scenario where this will backfire?
Try using the Edit Paste Special command, it will give you some controls to choose what to do with the data.
For a taste of the complexity of what is really going on underneath, look in MSDN about Clipboard Formats. In short, it isn't all Excel's fault...
A common user trick copying data out of excel is to paste it into Notepad and cut it back to the clipboard, which flattens all the formatting down to plain text. It won't help you for pasting data into Excel, however.
Copy-paste in windows retains formatting. One way to get rid of the formatting is to paste the text into e.g. notepad first, then select and copy it again. This loses any copied formatting.
Related
Disclaimer - this should be a very simple task, but clearly everything I thought I knew about excel is false.
I'm trying to copy and paste data from a txt document to an excel document. An example of a line I'm trying to copy from the txt doc is: 4512544425701264.
However, when I paste into excel it pastes as 4512544425701260 but displays in the cell as 4.51254E+15. This happens for each line of data.
I've tried numerous ways to fix this problem none have worked including:
Copied the txt data into a Microsoft Word document, then tried
pasting into the excel.
Resized the cell.
Tried each cell formatting option.
Tried opening the txt doc in Excel, even progressed through the text import wizard. Interestingly, I noticed the data preview on page 3 displayed the data correctly. But after proceeding past the importer, the data loaded with the same problem.
Tried on another PC.
Copied and pasting one line at a time.
The only solution I have found is manually typing out each line, however this is highly unpractical due to the large amount of data.
Any help/advice would be greatly appreciated.
To show full number rightclick on cell, choose "Format cells..". In "Number" tab choose "Number" category and set "Decimal places" to zero.
Unfortunately excel lets to put only 15 digits as a number. Every additional number is converted to 0, that is why your number 4512544425701264 is converted to 4512544425701260
If you don't need this number to be used in calculation, you can format cells to text format before pasting:
Source on digits limitation: https://learn.microsoft.com/en-US/office/troubleshoot/excel/last-digits-changed-to-zeros
In Excel, this is expected behavior (it's Microsoft, after all). I have encountered it frequently when dealing with UPC codes, for example. In order to avoid this, format the cells you are trying to copy this data to as "Text" BEFORE you copy any data over.
Copy your data (CTRL+C), then select the first cell in the range where the data is going, then paste only the values. This should take care of it.
If for some reason you still get scientific notation, provided the cells have the "Text" formatting, you can select that cell, click in the Formula bar and hit ENTER.
When you paste into Excel, try calling "Text import wizard" in the Paste Options. This will allow you to set delimiter (in case of CSV) and later data type of a column where you can select "Text" which will tell wizard not try to convert your data into numbers.
I've seen some stuff online about exporting data, but what I'm doing is a Copy/Paste. I'm looking at a Datasheet View of an Access form, and I'm trying to copy it to Excel. The form has 2 Memo fields.
If I copy the Memo fields one at a time, I get all the contents of the field. If I try to copy the whole Datasheet View and paste it into Excel, the Memo fields get truncated.
Is there a way around this, other than exporting the data?
No, you need to export.
Note that the error is in Excel, not in Access - if you paste to a text editor, or view the copied data in Clipboard Viewer, you see that the clipboard data is complete.
But when you paste multiple cells to Excel, it truncates each cell at 255 characters.
If you Paste Special into Excel your text from Access will not be truncated. But check to make sure funny things didn't happen in other columns of your Excel worksheet. And you will end up with with a top line header you'll probably want to delete. Small price to pay for getting all the text over.
I want to print a row in Excel.
One row contains data for one project.
I want to print one row on one page nicely formatted. Meaning the value of one cell is the header and should be printed fat and centred, the other values should also be placed at fixed positions on the page.
Is this with VBA possible? When I was searching for this problem I only found results for printing a worksheet or a table or parts of it, but no results to use the values of the cells and formatting them.
Thanks in advance
As the other answers indicate, it is certainly possible in Excel VBA, but it is not really Excel's strong point.
What would typically be done to obtain the result you seem to be after is use a fully formatted Word document with fields that are then filled in with values from an Excel worksheet. You can even cheat a bit and use the Mail Merge \ Letter wizard to set everything up.
If you do want to do it all in Excel, you can find instructions and an example VBA macro here:
http://www.tek-tips.com/faqs.cfm?fid=4223
Template is a good way to do. With a macro there's better performance where it avoids the usage of volatile functions such as INDIRECT() However again it depends on how many volatile functions your worksheet carries.
Yes, it is possible when you use the Styles in excel. I know you can do Font formatting quite easily. Not sure about indenting it, but worth a try.
If style doesnt support it (it might in Excel 2010), you can always indent it via VBA (record a macro when you indent the values , it should look like this):
Selection.InsertIndent 1
I know there are other similar threads on SO, but they suggest formating the cells to text and/or prefixing the cells with a '.
I've done them both, and it works fine in Excel 2007, but when I open the exact same Excel template in Excel 2003 and paste the same source, it removes the leading zeros. Are there any other possibilities? Could one make a macro something?
EDIT: I found a solution for a different problem that solves this as well. Similar problem. Record a macro that uses 'Paste Special' as text, and override ctrl-v on that spreadsheet.
If you use a leading ' then it should work.
Just select cells with data, right click, choose format, select custom and type the same number of zeros that You want to display (it is better explained here).
Group I am pasting data from SQL to Excel and it appears that Excel is trying to read my mind by converting some of my numbers to dates. I.e. one number is 2-2131 and when I paste it to excel it shows Feb-31 even 2-3291 wnats to be Feb-61
STOP IT EXCEL!
This is driving me crazy and I can't seem to find an easy way around this. I tried "paste special" as text and it still formats. I can get it to work if I create a connection and use the query, but I just want to be able to copy-paste data for testing purposes.
Anyone have an easy solution to my headache?
Thanks in advance!
Format the column as text before pasting the text.
Select the cells ahead of time and mark the formatting as Text. (Format->Cells, select "Text" from Categories and click OK). Then paste your data.
Hit F-2 before you paste the code and then it just puts it into one cell.
Highlight the affected row, right click, choose Format Cells..., select Text before you paste the data.
After pasting the sql data to excel, change the date and time format of excel to simple numbers seprated by dashes. That way round even if excel would assume it to be date, it would display the numbers as it is.