A B
1 2020-01-01 2020-01-01 =TEXT(A1,"YYYY-MM-DD")
2
3
In my spreadsheet I have a date written in Cell A1 and change it to a TEXT format with the formula in Cell B1.
All this works fine as long as I use the English version of Excel.
Now, a coworker in Poland needs to use the file in a polish Excel version.
Once he opens the file the formula in Cell B1 changes to:
=TEKST(A2;"YYYY-MM-DD")
This formula gives back an error because in Poland instead of YYYY-MM-DD you need to use RRRR-MM-DD.
Therefore, I am wondering if it is somehow possible to make this text formatting international so no matter in which language your Excel is set up the formula is working?
If the only problem is sharing it with your Polish co-worker, then you can simply use the international placeholder "e" to replace "YYYY":
=TEXT(A1,"e-MM-DD")
Now, while this would work fine for your co-worker in Poland, there are countries where "m" and "d" would also need replacement. If in general we need to return the locale "Y", "M" or "D" equivalent you could create three named formulas using the name manager:
1st: Create name called YT and refer to =INDEX(GET.WORKSPACE(37),19)
2nd: Create name called MT and refer to =INDEX(GET.WORKSPACE(37),20)
3rd: Create name called DT and refer to =INDEX(GET.WORKSPACE(37),21)
Now you can use a reference to these names through:
=TEXT(A1,REPT(YT,4)&"-"&REPT(MT,2)&"-"&REPT(DT,2))
NOTE: Depending on which version of Excel you use it could be necessary to:
Enable Excel 4.0 macros when VBA macros are enabled in the Trust Center
Another option with no macros is to use FORMULATEXT:
In a random cell Z5
=TEXT(123, "foo")
Then in your desired cell C1
=TEXT(A1,IF(ISERROR(SEARCH("TEKST", FORMULATEXT(Z5)), "YYYY", "RRRR") & "-MM-DD")
This works because the formula of the random cell will be updated to say TEKST in polish and you can just spot that happening. Obviously the other method is more robust to any country but this requires no settings to be changed.
Bigger:
=TEXT(
A1,
IF(
ISERROR(
SEARCH(
"TEKST",
FORMULATEXT(Z5)
),
"YYYY",
"RRRR"
) & "-MM-DD"
)
The solution is actually simple, surprisingly so.
Whether specifying a formal Custom Format, or specifying a format inside a TEXT() (or TEKST() function), you just add the country-specific code for interpreting the formatting string. So, if a US-Excel version person is writing the formula, and is presumably most conversant in the US English strings to use, and especially if expecting the users to be US-Excel version users, he would write it as:
=TEXT(A1,"[$-en-US]YYYY-MM-DD")
Every version of Excel will then use the US English set of formatting string variables in interpreting the formatting string that follows the [$-en-US]. Since the string is perfectly valid in US English Excel, it will form the date properly and "textify" it as demanded. No error will be produced.
I cannot test a nuance here, that of whether Excel of a different language version will insert itself into the middle here and take the date as the string formats it, and map it to the particular language's names for months, but that is not asked for in the poster's question so... I have the feeling it will not and so one might need to do further work to make the Polish user happiest. If month names were used instead of month numbers.
But the key element of generating a correct numeric date display with no possibility — none at all — of an #ERROR! result rendering things ugly and useless will absolutely be accomplished with no great effort at all.
Related
A B
1 2020-01-01 2020-01-01 =TEXT(A1,"YYYY-MM-DD")
2
3
In my spreadsheet I have a date written in Cell A1 and change it to a TEXT format with the formula in Cell B1.
All this works fine as long as I use the English version of Excel.
Now, a coworker in Poland needs to use the file in a polish Excel version.
Once he opens the file the formula in Cell B1 changes to:
=TEKST(A2;"YYYY-MM-DD")
This formula gives back an error because in Poland instead of YYYY-MM-DD you need to use RRRR-MM-DD.
Therefore, I am wondering if it is somehow possible to make this text formatting international so no matter in which language your Excel is set up the formula is working?
If the only problem is sharing it with your Polish co-worker, then you can simply use the international placeholder "e" to replace "YYYY":
=TEXT(A1,"e-MM-DD")
Now, while this would work fine for your co-worker in Poland, there are countries where "m" and "d" would also need replacement. If in general we need to return the locale "Y", "M" or "D" equivalent you could create three named formulas using the name manager:
1st: Create name called YT and refer to =INDEX(GET.WORKSPACE(37),19)
2nd: Create name called MT and refer to =INDEX(GET.WORKSPACE(37),20)
3rd: Create name called DT and refer to =INDEX(GET.WORKSPACE(37),21)
Now you can use a reference to these names through:
=TEXT(A1,REPT(YT,4)&"-"&REPT(MT,2)&"-"&REPT(DT,2))
NOTE: Depending on which version of Excel you use it could be necessary to:
Enable Excel 4.0 macros when VBA macros are enabled in the Trust Center
Another option with no macros is to use FORMULATEXT:
In a random cell Z5
=TEXT(123, "foo")
Then in your desired cell C1
=TEXT(A1,IF(ISERROR(SEARCH("TEKST", FORMULATEXT(Z5)), "YYYY", "RRRR") & "-MM-DD")
This works because the formula of the random cell will be updated to say TEKST in polish and you can just spot that happening. Obviously the other method is more robust to any country but this requires no settings to be changed.
Bigger:
=TEXT(
A1,
IF(
ISERROR(
SEARCH(
"TEKST",
FORMULATEXT(Z5)
),
"YYYY",
"RRRR"
) & "-MM-DD"
)
The solution is actually simple, surprisingly so.
Whether specifying a formal Custom Format, or specifying a format inside a TEXT() (or TEKST() function), you just add the country-specific code for interpreting the formatting string. So, if a US-Excel version person is writing the formula, and is presumably most conversant in the US English strings to use, and especially if expecting the users to be US-Excel version users, he would write it as:
=TEXT(A1,"[$-en-US]YYYY-MM-DD")
Every version of Excel will then use the US English set of formatting string variables in interpreting the formatting string that follows the [$-en-US]. Since the string is perfectly valid in US English Excel, it will form the date properly and "textify" it as demanded. No error will be produced.
I cannot test a nuance here, that of whether Excel of a different language version will insert itself into the middle here and take the date as the string formats it, and map it to the particular language's names for months, but that is not asked for in the poster's question so... I have the feeling it will not and so one might need to do further work to make the Polish user happiest. If month names were used instead of month numbers.
But the key element of generating a correct numeric date display with no possibility — none at all — of an #ERROR! result rendering things ugly and useless will absolutely be accomplished with no great effort at all.
I would like to know how to split a cell in Excel after the first space. Using Google I came across:
=LEFT(C2,FIND(" ",C2)-1) (Formula 1 In D2)
=RIGHT(C2,LEN(C2)-FIND(" ",C2)) (Formula 2 In E2)
And that should do exactly what I want and need but sadly Excel (Office 2013) just tells me that the code is supposed to have an error.
For example my Table looks like this : (// means new cell)
Value// Formula 1 // Formula 2
BRAND ID1 ID2 ID3// Formula 1// Formula 2
Short answer for a German Excel:
=LINKS(C2;FINDEN(" ";C2)-1)
=RECHTS(C2;LÄNGE(C2)-FINDEN(" ";C2))
Unfortunately, Excel behaves differently in different languages (Obviously the worst thing the developer of a programming language can do).
In detail, the following things are known to depend on the language:
Argument separator: English uses comma (,) where German and probably other languages use semicolon (;). The actual value is taken from the regional settings in windows (thx to Jeeped).
Error message in Excel: "The formula contains an error"
Function names: They are normally different for every supported language. You have to try their translation or lookup them. There are also translations tables in the www.
Error behaviour in Excel: The cell value shows: "#NAME!"
I'm having trouble trying to figure out a way to have two columns, one to show the entire formula that can be editable and the second to actually perform the formula.
Ideally, I would like my sheet to be set up like this:
Formula | Value
=5+2 | 7
=3-2 | 1
I would like to be able to change the Formula column and have it automatically update the Value column.
I've tried using the GetFormula() function but I don't think that's what I want to do as I would end up in a circular reference based on what I want to do. The closest I've got is using a Right() function and Text in the formula column or a space and removing the space. However, I end up with the text and not the solved formula instead.
Using =RIGHT(A2, LEN(A2)-1)
Formula | Value
=5+2 | =5+2
I have also tried using =RIGHT(A2,LEN(A2)-1) but without the "=" and can't figure out how to convert the "5+2" into text that I can use to solve. I'm hoping to do this with a formula and without a macro/VBA.
Here is how to do it.
1
Open the Name Manager. Control-F3 from the worksheet, and then click the New button.
2
For the Name field in the dialog, enter EVALA. I just picked this name; it stands for "Evaluate A". But you can pick whatever name you like.
3
For the Refers to field, enter this
=EVALUATE($A1)
4
Click OK and then Close.
5
In B1 enter this formula:
=EVALA
That's it.
You can now use this formula on any row in the worksheet and it will evaluate whatever is in the column A cell of the row where you enter the formula.
You can make a user defined function easily enough with VBA, but if you don't regularly use VBA then an alternative method is to create a Name object. Name objects can access certain functions not typically available in a cell's formula. One of these functions is "Evaluate" which will evaluate a string as a mathematical expression. Here's a demonstration how to do this.
NOTE: Pay special attention to the use of $. Chances are you don't want any $ in your name definition since that will prevent it from behaving in a relative manner. Also, Sheet1! means that this will not work on another sheet.
Update I just want to give credit for this method to the following sources. This is pretty neat stuff, so for anyone interested give it a read. The last link in particular gives a neat example of creating a chart with no data points.
MSDN Evaluating Defined Names
The power of evaluate (ozgrid)
XL4 Macro Functions in Names - JKP
Evaluate and Indirect
More unique functionality of Defined Names
This is probably the best solution for the OP, since it asks to avoid using VBA; however, this method is somewhat limited. It requires manual set-up on every sheet to be used. Much preferable I think is to create a very simple UDF like this...
Function Eval(Expr As String)
Eval = Application.Evaluate(Expr)
End Function
This can be added to any accessible add-in, making it available to any instance of Excel. A little more set-up, but less maintenance.
Just put a single ' before the formula in your A column:
'=5+2 will show in your cell as "=5+2". Then in the B column, just do the formula as normal, =5+2.
I want to combine some text with a date in Excel 2013.
Let's say I have a cell A2 with a date like 30-10-2014. I tried to append the date after the text with this formula:
="Some text and a date: "&A2
But the output shows the date as a number: Some text and a date: 41942
So I tried it with the TEXT formula:
="Some text and a date: "&TEXT(A2;"dd-mm-yyyy")
But this shows Some text and a date: 30-10-yyyy and not Some text and a date: 30-10-2014
So or I do not understand how the TEXT formula works or is there some bug / issue here?
UPDATE: It looks like it's important that I have a Dutch version of Windows (7) but an English version of Excel (2013) which causes this issue!
All kudos go to #AxelRichter, thanks Axel!
It looks like that if you have a Dutch Windows but an English version of Excel (2013) the formulas get mixed up. For example, I still have the English formula names like TEXT (which would be TEKST in Dutch) but still have to use a colon instead of a comma in the formula. The format_text value of TEXT still expects the Dutch format which is different for the year (jjjj instead of yyyy).
So if you have a Dutch Windows and an English Excel version the correct formula for some text followed by a formatted date would be:
="Some text and a date: "&TEXT(A2;"dd-mm-jjjj")
I hope Microsoft will fix this, this is very annoying!
You can now use 'e' instead of 'yyyy'. The e is the universal version of yyyy a
we have the same issue at our work and I found that if I cannot influence the localization of the windows then I use a formula which in your case looks like:
="Some text and a date: "&TEXT(A2;"dd-mm-")&YEAR(A2)
It is funny that "dd" and "mm" is the same.
Excel here obviously fails. TEXT should be language agnostic.
The workaround I found, especially if you have multiple cells to format:
Calculate the desired date format in a hidden cell or white colored:
=IF(TYPE(VALUE(TEXT(DATE_CELL;"YY")))=1;"DD.MM.YYYY";"ДД.ММ.ГГГГ")
If you need, it can be extended to support multiple regions like:
=IF(TYPE(VALUE(TEXT(DATE_CELL;"YY")))=1;"DD.MM.YYYY";IF(TYPE(VALUE(TEXT(DATE_CELL;"ГГ")))=1;"ДД.ММ.ГГГГ";"DD.MM.JJJJ"))
On cells where you need dates, use previous cell as second parameter:
="Date: " & TEXT(DATE_CELL; FORMAT_CELL)
For same problem when your system or keyboard is Danish then use åååå in place of jjjj. I also struggled a lot to find this key.
However if anyone facing same problem apart from Dutch or Danish then you can check which key is correct. To find it right click on any cell and goto 'Format Cell' then select 'Custom' and find date related formats in your local language. There you can find which is the right key to be used for DATE format in your local language.
This issue is still there on Excel 2016 (or Office 365, if you may). It is caused by different language settings in Windows. This happens for languages that have different year symbols (dutch is 'jjjj', portuguese is 'aaaa'). If you're experiencing this problem, try using your local Windows language's year format.
This should work regardless of your system language or regional settings:
="Some text and a date: "&TEXT(DAY(A2);"00")&"-"&TEXT(MONTH(A2);"00")&"-"&TEXT(YEAR(A2);"0000")
Click here to see it working
[Edit] I just tested the solution with German (TT.MM.JJJJ) and English settings (DD.MM.YYYY) and it works fine!
You may need to use , instead of ; in the MS EXCEL formula (depending on your actual list separator symbol --> check your OS settings!).
Solution: To check if "jjjj" format is working:
The date you want to display in a certain format is in A1
In cell A2 link a cel to the cel with the date you want displayed in a certain format with the following formula:
=TEXT(A1;"dd/mm/jjjj")
In a 3rd cel you then place the following formula:
=IF(RIGHT(A2;4)="jjjj";TEXT(A1;"yyyy");TEXT(A1;"jjjj"))
If the 4 digits from the right are "jjjj" this formula will display the date formatted as "yyyy" else the formatting "jjjj" will be used.
The easy fix, whether directly custom formatting a cell or using TEXT(), is to use a country code for a language you know the proper formatting codes for.
For instance, I am in the US, have a US version of Excel, and am familiar with its date code formats. So I'd want to use them and to ensure they "come out" regardless of anyone's Windows or Excel version, or the country they are in, I'd do it like the following (for TEXT(), let's say, but it'd be the same idea in custom formatting):
=TEXT(A1,[$-en-US]"dd-mm-yyyy")
The function would collect the value in A1, ask Excel to treat it as a date, Excel would and would say fine, it's cool (i.e.: the value is, say, 43857 and not "horse") because it is a positive number which is a requirement for anything to be treated as a date, and let the function move on to rendering it as a date in the manner prescribed. Rather than giving an #ERROR! as it would for "horse" or -6.
The function would then read the formatting string and see the language code. It would then drop the usual set of formatting codes it loaded upon starting up and load in the formatting codes for English ("en") and in particular, US English ("US"). The rest of the string uses codes from that set so it would interpret them properly and send an appropriate string back to TEXT() for it to display in the cell (and pass on to other formulas if such exist).
I have no way to test the following, but I assume that if one were to use a format that displayed day of the week names or month names, they would be from the same language set. In other words, Excel would not think that even though you specified a country and language that you still wanted, say, Dutch or Congolese month names. So that kind of thing would still need addressed, but would be an easy fix too just involving, say, a simple lookup one could add though it'd be "fun" setting up the lookup table for each language one wanted to accomodate...
However, the basic issue that arises here, and with this problem in general, is very, very easily solved with the country codes. They aren't even hard or arcane anymore now that the [$-409] syntax has been replaced with things like [$-en-us] and [$-he-IL] and so on.
If VBA is an option... works for any locale/language
Public Function dateYYYYMMDD(dt As Date) As String
dateYYYYMMDD = Format(dt, "yyyyMMDD")
End Function
I could probably puzzle this one out in VBA, but would rather not have to use that approach if possible, and it seems like this is something Excel's built-in functions should be able to manage.
I have a spreadsheet we recently stopped printing that we would use to verify data came in from our various sites, and for which days. Column headers correspond to site numbers ($D$1:$AU$1 for this spreadsheet) and rows are for dates ($A$3:$A$24 for the month of December -- we don't do this data validation on weekends). The "B" column contains the date whose information SHOULD have come in, for example, on 12/4, we should receive the information from 12/2 at each site.
In the past, we used column "C" to write which sites were behind. If Site 3 only sent in information from 12/1 on the 4th, we would write a "3" in that column. I'd like to continue this convention, since it's what the office understands. Change Is Bad and all that.
So far I've muddled through on my own and wrote an Array Formula that returns {0,0,1,0,...,0} if only site 3 is behind. That formula is =IFERROR(SEARCH(B3,D3:AU3)-SEARCH(B3,D3:AU3),1)
From here it's trivial to do =IF(ISBLANK(D4),"",INDEX(D1:AU1,1,MATCH(1,IFERROR(SEARCH(B3,D3:AU3)-SEARCH(B3,D3:AU3),1)),0)) which works great, so long as there's only one site that's behind. If we have more than one site behind, it returns the first value (as expected).
If both sites 3 and 6 are behind, we want to see "3, 6" (or any other human-readable format) but the only solutions I found are to write a custom VBA script to concat an array. I'd rather stay away from custom VBA if humanly possible.
Thanks,
Adam
Try this "array formula" in BA3
=IFERROR(INDEX($D1:$AU1,SMALL(IF(ISERROR(SEARCH($B3,$D3:$AU3)),COLUMN($D3:$AU3)-COLUMN($D3)+1),COLUMNS($BA3:BA3))),"")
confirm with CTRL+SHIFT+ENTER and copy across to get all matches
As you say you can then concatenate those back to C3