Error using concatenate - excel

I try to merge text with date in a single cell. I looked online and I found the following options:
=G5&TEXT(F5;"DD/MM/YYYY")
And
=CONCATENATE("ZIMMERMANN U-4600 ";TEXT(F5;"DD/MM/YYYY")).
Unfortunatelly , nothing works, although in the other forums everybody was happy with the result. I get a #VALUE! - error.
I played around with the formatting and the languages of windows while giving in the code but nothing helped.
The code has ; instead of , due to the fact that it is a european office-package (and it doesn't work with "," either).

I suspect the #VALUE! error is coming from the TEXT(F5;"DD/MM/YYYY") part. Do trying it alone in a cell as =TEXT(F5;"DD/MM/YYYY"). If this also is resulting in #VALUE! error, then this is the case.
Unfortunately the pattern "DD/MM/YYYY" in TEXT function must be according to the locale settings of the Excel and the system the Excel is running on. In German Excel it must be
=TEXT(F5;"TT/MM/JJJJ") for example.
Have a look at Control Panel - Region what pattern is used for dates there. Then do using the same in TEXT function.
See TEXT function -> Other format codes that are available for another method getting possible format codes directly from the Excel.
This is a big disadvantage of the TEXT function if the Excel file shall be exchanged between different users from different locales.
Better approach then would be:
=TEXT(DAY(F5);"00")&"/"&TEXT(MONTH(F5);"00")&"/"&TEXT(YEAR(F5);"0000")
since the pattern 0 is locale independent.

Related

Why does carriage return in excel is not reflected when excel value is imported in UFT

I am using Excel to compare error messages. My error message looks like this .
You have changed the values.
Do you want to continue?
I entered this value in excel using Alt+Enter, when reading this value from UFT, this carriage return is not considered.
How to include carriage return in excel so that it is visible when reading the values from UFT?
First, try to create a string formula, i.e. instead of entering the line break in the string, create a formular like
="<value>"
where <value> is the string value that you originally wanted in your cell, with the line feed contained within the quotation marks.
This might solve your issue.
But:
This is just the top of the mountain of known issues with UFTs data table API. Here is an incomplete list of additional issues (some of which, but not all, are fixed or at least improved upon in 15+):
Date values are not properly handled, especially if you are using a
non-US locale and try to consume values auto-formatted by Excel as
dates
Strange things happen if you have an .xls file. Use an .xlsx file instead. (This used to be the other way around). Note it is not only the extension I am referring to, but also the format (Excel-95 vs. more modern format)
Many formulas are unsupported Formatting behavior differentfrom what Excel would do/show
CRs and LFs are handled differently
from what Excel does
Built-in table editor is quite a silo of bugs
and antiergonomic cell values are limited in length; at the same
time, formulas have different length limits. I.e. a string in a cell is
limited to a certain maximum number of characters, but a formular
returning a string does not have that (but maybe a higher) length
limit
Because of this (and more), we auto-convert all excel sheets on the fly before when we use them in UFT after they have been updated. To do this, we are using Excel Interop (i.e. Excel´s COM automation interface) to spawn an Excel instance, create a converted version that has all formulas and formatting resolved to just string formulars, and use the converted sheets with UFTs DataTable.ImportSheet feature. Which means we unfortunately need Excel on all execution machines.
So my recommendation would be to stay away from the data table editor in UFT. Use Excel, and make sure all your edits come through to UFT in a meaningful way. If they don´t, consider a converter that creates a DataTable-compatible copy of your sheet.
Yes, I know this is suboptimal, but that´s what it has come down to after years and years of struggling with the DataTable API and UFTs "superb" built-in data table editor.

Getting the excel displayed value

I've been scouring for days and I can't seem find what should be an easy answer. The displayed value is not necessarily the value that from cell.InnerText. I see post after post that requires you to look at the cell.StyleIndex property & cell.DataType.value to determine how to get the displayed value. And while I have plugged in some of this code and it works I hit another case I didnt handle where the cell StyleIndex is null which I can only assume the cell is formatted as "General". The on screen value "-39718.96" while the cell.InnerText returns "-39718.959999999999". I realize there is a easy fix to this by Double.Parse(value).ToString() but there seems to be an endless supply of formats https://stackoverflow.com/a/4655716/1713000 and that's a shortlist and dates are another problem. It seems we are left to handle each different style ourselves. Did Microsoft really not create a public api that returns the formatted displayed value and has no one really written a complete solution to handle this cluster of a mess?
Using Openxml for sheets is very difficult (much more so than using it for Word). If I were you I'd use the ClosedXMl nuget package as it simplifies Openxml for sheets.
Will use the ClosedXML lib instead

What is wrong with my excel formula syntax?

I have made several formula to dynamically create a SQL query but to make it perfect, I want to add a condition : "if cell is not blank".
I've tried a lot of different syntaxe but even with a very simple one (see exemple below), I get an error.
My formula is :
="""" & SUBSTITUE(E2;"'";"''") & """"
It works well and give me "Accordéoniste d''hier"
I've tried
=IF(E2<>"";"""" & SUBSTITUE(E2;"'";"''") & """";"")
Excel display #NOM? in the cell but doesn't give me an explicit error.
I've tried a very simple one, but I get the same result : #NOM?
=IF(1=1;"Delivered";"")
I've tried ISBLANK but same result... I think there is something wrong and I don't see it...
Thanks for your help !
#rory is totally right. It looks like your Excel is in French, so you need to use SI instead of IF.
Excel works with local formulas, so you need to know the name of the functions in whatever language Excel has been set up.
Stack Overflow always post answer in english, and sometimes users like me need the translation of a function to their native languages. There's a trick to get the name of a function in a specific language I've used hundreds of times and it works pretty good with Stack Overflow.
Let's see your case. You see the solution is using the function IF and you need to know how is called that function in your language.
Of course there are several sources in Internet where you can check, but I like to use this one:
Google for the function in english, using words Excel Function. Always use the link that starts with https://support.office.com
Using that link will take you to the official documentation about that function, in english, but check the URL, the part of the language (in image it says en-us)
Change en-us for the initials of the language you want to see, and navigate to that new url. I don't know all of them but some of them are fr-fr for french, es-es for spanish, pt-br for portuguese (brazilian), pt-pt for portuguese, de-de for german, and so on.
In your case, you want in in french so replace en-us with fr-fr and you will see the name of the function in french. Same works for ISBLANK and other functions.
There you go. Now you know the name of the function in french, and you can apply it to your needs. This trick works for all functions documented in Excel. Hope it can help other users.

Excel - Variable number of leading zeros in variable length numbers?

The format of our member numbers has changed several times over the years, such that 00008, 9538, 746, 0746, 00746, 100125, and various other permutations are valid, unique and need to be retained. Exporting from our database into the custom Excel template needed for a mass update strips the leading zeros, such that 00746 and 0746 are all truncated to 746.
Inserting the apostrophe trick, or formatting as text, does not work in our case, since the data seems to be already altered by the time we open it in Excel. Formatting as zip won't work since we have valid numbers less than five digits in length that cannot have zeros added to them. And I am not having any luck with "custom" formatting as that seems to require either adding the same number of leading zeros to a number, or adding enough zeros to every number to make them all the same length.
Any clues? I wish there was some way to set Excel to just take what it's given and leave it alone, but that does not seem to be the case! I would appreciate any suggestions or advice. Thank you all very much in advance!
UPDATE - thanks everybody for your help! Here are some more specifics. We are using a 3rd party membership management app -- we cannot access the database directly, we need to use their "query builder" tool to get the data we want to mass update. Then we export using their "template" format, which is called XLSX but there must be something going on behind the scenes, because if we try to import a regular old Excel, we get an error. Only their template works.
The data is formatted okay in the database, because all of the numbers show correctly in the web-based management tool. Also, if I export to CSV, save it as a .txt and import it into Excel, the numbers show fine.
What I have done is similar to ooo's explanation below -- I exported the template with the incorrect numbers, then exported as CSV/txt, and copied / pasted THOSE numbers into the template and re-imported. I did not get an error, which is something I guess, but I will not be able to find out if it was successful until after midnight! :-(
Assuming the data is not corrupt in the database, then try and export from the database to a csv or text file.
The following can then be done to ensure the import is formatted correctly
Text file with comma delimiter:
In Excel Data/From text and selected Delimited, then next
In step 3 of the import wizard. For each column/field you want as text, highlight the column and select Text
The data should then be placed as text and retain leading zeros.
Again, all of this assumes the database contains non-corrupt data and you are able to export a simple text or csv file. It also assumes you have Excel 2010 but it can be done with minor variation across all versions.
Hopefully, #ooo's answer works for you. I'm providing another answer mainly for informational purposes, and don't feel like dealing with the constraints on comments.
One thing to understand is that Excel is very aggressive about treating "numeric-looking" data as actual numbers. If you were to open the CSV by double-clicking and letting Excel do its thing (rather than using ooo's careful procedure), those numbers would still have come up as numbers (no leading zeros). As you've found, one way to counteract this is to append clearly nonnumeric characters onto your data (before Excel gets its grubby hands on it), to really convince Excel that what it's dealing with is text.
Now, if the thing that uploads to their software is a file ending in .xlsx, then most likely it is the current Excel format (a compressed XML document, used by Excel 2007 and later). I suppose by "regular old Excel" you mean .xls (which still works with the newer Excels in "compatibility mode").
So in case what you've tried so far doesn't work, there are still avenues to explore before resorting to appending characters to the end of your data. (I'll update this answer as needed.)
You're on the right track with the apostrophe.
You'll need to store your numbers in excel as text at the time they are added to the file.
What are you using to create the original excel file / export from database?
This will likely be where your focus needs to be regarding your export.
For example one approach is that you could potentially modify the database export to include the ' symbol prefix before the numbers so that excel will know to display them as text.
I use the formula =text(cell,"# of zeros of the field") to add preceding zeros.
Example, Cell C2 has 12345 and I need it to be 10 characters long. I would put =text(c2,"0000000000").
The result will be 0000012345.

Importing Excel into SS2000; Error on Field; DTS

I'm trying to import an excel file in to a SQL Server 2000 database using DTS. This is nothing fancy, just a straight import. Where I work, we do this 1000 times a day. This procedure usually works without an issue but something must have changed in the file.
I'm getting the below error:
Screen shot of Error http://www.understandingguitar.org/wp-content/uploads/2008/12/packageerror-screenshot-20081212.jpg
I've checked to ensure that the column "AssignmentID" is stored as "text" in the excel sheet. I've also tried to change it to general. Exact same error regardless of setting. The field does contain numbers... I appreciate everyone's help on this!
Regards, Frank
Try opening at the excel file and see the column content.
Is any of the row value in that column right-aligned? (generally for numbers)?
I am guessing that such a row could be a problem.
It may be obvious, but is the destination string long enough to hold the string representation of the float? I'm not sure if Excel is rounding what it displays to you, so it may be worth trying with a wider column.
The answer has something to do with the fact that the procedure is expecting text but even if you set the properties (in the format dialog) to "text", excel may not handle the data as text. And hence, SQL Server (or the libraries) won't handle it to text.
When the procedures try to import it, the system feels that it is converting from a number to text and it expect that data maybe lost (even though no data will be lost) and the error is raised.
If figured out that I can get around this error by placing a ' (apostrophe) before each listed number. [I.E. '124321] This force excel to treat the number as text.
Hopefully this will save others the headache I now have from this. :-)
Regards,Frank

Resources