I have an Excel spreadsheet with a range of values which are numbers that go to up 20 decimal places, unpivoted from another sheet using the trick from here.
The trouble is the cells are only displaying 10 digits so, for example, even though the value is 5.46827166811115 it is showing as 5.468271668.
I've tried setting the format to text but it still wants to treat it as a number, the number of decimal places varies so I can't use a fixed #.### format. The only way I can get it to show is to format the cells as text and to just select and then click in the entry box for each and every cell!
It then shows a warning that the number in the cell is formatted as text or preceded by an apostrophe but at least it's showing the full value.
I did find a VBA script that just did something stupidly simple like cell.Value = cell.Value for the selection which seemed to work but I can't find it anymore and I can't reproduce that now.
Surely there's an easier way to do this? It wouldn't matter so much but when I import this data through SSIS into a VARCHAR(MAX) it's getting the truncated values!
Pre-pend a single apostrophe ' to the data. In many cases, this is more effective than setting the cell format to text.
You could format the cell as text and the do an .AutoFit so the cell expands to show all the cell content, like this:
Columns("A:A").EntireColumn.AutoFit
that will expand the A:A cell so all its content is visible.
try formatting with #.000 instead of #.###, but if your problem is that Excel is dropping precision on you, you could try multiplying the value by 10^20, then dividing by 10^20 on the SQL side.
found more info:
here
looks like Excel is limited to 15 digits of precision, multiplying by 10^20 doesn't increase the precision, so you can treat it like text or split the remaining digits into another column and combine them back with SSIS or SQL.
Have you added the IMEX=1 to your connection string? That keeps SSIS from trying to figure out the data from the first few rows.
Also, what about using a decimal datatype instead of varchar(max)
Related
I am exporting a report in exel format, however, for customer identifiers that are more than 12 digits, the exel displays them as decimals eg 9876520220007 is displayed as 9.88E+12 or as 9.876520220007. This makes it very hard to verify data because the customer identifier is used to check if the records are correct. Any recommendations or links on how i can display the full number will be apreciated. Thanks
My data:
Link to sheet : here
How are you getting the data into excel? Is it via a csv?
In which case you can use the get data from file option which lets you specify the column type as text before excel messes with it.
You can also set the column format to text. This doesn't fix the ones that excel has already interpreted as a long number but any new ones you paste or type in will stay as text.
You can also put an apostrophe before the text in the cell which forces it to be text.
Thats the only one I can suggest up to now as I don't know how you are getting the data into excel.
Select the column and right-click to format cell, and set the decimal place to 0 that should do the trick. but I see you have different types of data in the column you might need to update it individually depending on the case
but I see the
I want to convert the numbers from text format to numbers so tha i can make the average or sum of the whole columns.
I tried all the possible ways asfar as i read in many blogs, but nothing works.
There is no Green mark on the cell nor a quote '
Tried copying an empty cell and select required cells and paste special methods also.
It looks like you are using a French version of Excel. In this case a number should be 6,04 and not 6.04
Do a find and replace of . for , and you should be able to change the format to a number if it is not done automatically.
You can either:
change the values to numbers
use a formula that can handle text-type numeric values
Say we have data in column A that is Text. This formula:
=SUMPRODUCT(--(A:A))
can give you the sum without having to convert first:
Can Not Get My VLookUp In Excel To Return The Requested Data
I am trying to pull data from another sheet based on data selected from a dropdown on the main sheet.
All the formatting is "General"
=VLOOKUP(F15737,'Location Master'!$A:$J,2,FALSE)
It just keeps returning me #N/A
Try using the Index Match method. It's an alternative to Vlookup which doesn't require data to be sorted and can therefore be of more use.
The typical structure of this method is (the text inside the asterisk will give the ranges specific to your sheet:
=INDEX (**Column from which you want to return a value**, (MATCH(**Lookup Value**, **Column against which you want to lookup**,0))
In this case, if I've understood your workbook structure, the formula should look like this:
=INDEX('Location Master'!$B:$B,(MATCH(F15737,'Location Master'!$A:$A,0)))
This is a common problem with VLOOKUP(). Most likely you have some whitespace (A tab character or some spaces) after one of the values. Click on F15737 and see if there are any spaces at the end of it. Likewise, manually find the value in 'Location Master'!$A and check it for spaces or tabs after the value.
If the whitespace is found in F15737 then you can change your vlookup to be:
=VLOOKUP(TRIM(F15737),'Location Master'!$A:$J,2,FALSE)
If the whitespace is in the range to which you are looking up, then you'll need to trim all of those values, which you can do pretty quickly in a new column with the TRIM() formula.
If this doesn't solve the problem then you might have a number stored as text. Generally excel will tell you if this is the case within the cell with a little green corner indicator. To get Excel to automagically change a column from a "Number stored as Text" to a proper number you can:
Highlight the column
Go to Data>>Text To Columns
Click "Fixed Width"
Click "Finished"
Excel will then format everything automatically (dates to dates, numbers to numbers, text to text, time to time, etc.)
Using VBA, I import a csv file and put a bunch of data into several columns.
One of these columns has a date and time. As I need to be able to use just the 'time' part of these cells, I try to convert the entire column to Time by using (and just about every other variation)
Cells(x.y).EntireColumn.NumberFormat = "hh:mm:ss"
or
Range("C1").NumberFormat = "hh:mm:ss"
Range("C1").EntireColumn.NumberFormat = "hh:mm:ss"
However, this does not convert the entire column. I've tried every possible other way of selecting the entire column and changing it (through VB) however still only a portion remains converted.
If I doubleclick on these unconverted cells and press enter they change to the correct format. I realise this is a common problem relating to Calculations but my workbook is set to Automatic Calculations and I've tried setting this in VB too. This doesn't change anything.
The only pattern I can find is that the cells stop being converted when the Day reaches double digits. For example:
Column C
01/05/2013 7:28:56
03/05/2013 13:24:53
07/05/2013 20:13:24
09/05/2013 8:29:22
12/05/2013 9:28:56
15/05/2013 21:14:25
17/05/2013 7:28:56
Becomes:
Column C
7:28:56
13:24:53
20:13:24
8:29:22
12/05/2013 9:28:56
15/05/2013 21:14:25
17/05/2013 7:28:56
In the formula bar up the top for each cell it still shows the whole Date and Time for all cells, not sure if this is related, but doesn't seem to matter in terms of the calculations i have to perform using the Time.
Essentially I have to take the time for a cell in column C and the time from another Cell (also in Date/Time format) and check the difference. After some research I decided the best way was to convert all the cells to a time format and then do my calculations.
Alternatively I could try converting the column to text and using a Split function (using space as a delimiter) and pulling the time out, but I'm having trouble doing this too, as once again trying to convert the entire column to text stops at the double digits for date.
Thanks for reading through all that, any thoughts and help would be appreciated.
Edit: Realised some of my syntax was incorrect in my post, this was however correct inside my macro
another edit: I think this definitely has something to do with the date format... I just realised that before i format them, the dates are m/dd/yyyy and then when it gets to actual double digit days it changes to dd/mm/yyyy, and thats when the problem occurs...
In order to avoid confusion, and as the date always seems to occupy the same width, I recommend to
1) import this column as a text
2) then go over the whole column
For Each C In Range("A:A").Cells
If C <> "" Then
' ....
End If
Next C
3) cut away the leading 11 positions, e.g. C = Mid(C, 11, 99)
4) convert the remaining string to a time, e.g. C = CDate(C) (... yes it works with a time as well, because a time is a fractional part of a date)
Alternatively you may want to capture the date part and bring it into shape, too. See here for some ideas using worksheet formulas.
When numbers are stored as text in Excel you see this little guy http://imgur.com/zXdwD
in the upper-left hand corner. when you click on it it gives you the option of converting the text representation of a number to a number upon which math can be done. also, when stored as text numbers appear on the left side of the cell opposed to the right one. I have an array of numbers which are stored as text, but they don't offer that little green thing to convert them to numbers. It may sound trivial but I'm using the Vlookup function to reference a large column of numbers to a code name, but it's not being recognized. And the only thing I can think of is that it's somehow being read differently (the codes are most defintely in the lookup table, and ctrl+f will find them). I want to know if anyone has an idea about what's happening.
Thanks.
The smart tag is a little finicky at times. There's a couple of things you can do.
If you're using code, you can multiply the cells in the range by 1, this will convert them to a number.
Alternatively you can convert the number you're matching to a string and then vlookup. Something similar to:
=VLOOKUP(TEXT(A1,"#"),B1:D10,2,false)
Note TEXT(A1,"#") would round to no decimal places, you may have to adjust the formatting.
The format of some of the cells in the lookup table maybe formatted as text. If there are a lot of them you can create a macro that corrects them. I had the same issue in this SO question although it was the opposite problem.
Another way to correct them would be to copy all the cells in the lookup table in that column and in an adjacent blank column edit>paste special>values>add which makes each of them numeric. Then copy them and paste those back over the originating cells.
A quick trick to convert all numbers formatted as text back to umber format is to copy the data into the "Notepad" application. Then select and copy the data from "Notepad back into your spread sheet and everything will be converted to number format.