Get current culture using just formula for localization purpose

北城以北 提交于 2019-12-08 02:34:31

问题


Is there a way how to determine current system culture using a formula in Excel wihout using any VBA code?

I imagine something simple like this:

IF(CULTURE="sk-SK","Prehľad","Overview")

or also something like this would do for me:

IF(CURRENCYSIGN="€","Prehľad","Overview")

I am looking for a simple way to globalize XLSX file without any additional resources or files needed.


回答1:


No, there is no way to get system language settings without VBA. There is simply no built-in function for this. But if you consider UDF, there's a solution:

Public Function GetLang()
    GetLang = Application.LanguageSettings.LanguageID(msoLanguageIDUI)
End Function

However, with your help we have found a trick. You can guess the system language by analyzing formula text (only in Excel 2013):

A1=TODAY()
=IF(FORMULATEXT(A1)="=TODAY()",[some logic for English system],[some logic for non-English system])

Or by analyzing local month name:

=IF(TEXT(1,"mmmm")="January",[some logic for English system],[some logic for non-English system])


来源:https://stackoverflow.com/questions/28715106/get-current-culture-using-just-formula-for-localization-purpose

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!