VBA - 更改日期语言 [英] VBA - Change date language

查看:11
本文介绍了VBA - 更改日期语言的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试解决这样的问题:在我正在使用的宏中,其中一个部分是检索日期月份(全名),目前使用:

I'm trying to solve such problem: In macro, that I'm using, one of the parts is to retrieve date month (in full naming), currently is used :

LastMonth = Format(DateSerial(Year(Date), Month(Date) - 1, 1), "mmmm")

但随后出现了一个问题 - 对于使用不同区域语言设置的人来说,日期以当地语言显示,但我需要为每个人提供 英语.

But then one problem appears - for persons, who use different regional language settings, date appears in it's local language, but I need to have it for everyone in English.

我在互联网上四处寻找,但没有找到任何类似的解决方案.有谁知道,怎么解决?

I was looking around the internet, but haven't found any similar solutions. Does anyone knows, how can this be solved?

推荐答案

Excel 公式 TEXT 允许定义输出语言,因此其中一个选项是使用它的 VBA 等效项:

Excel formula TEXT allows defining output language, so one of the options is to use it's VBA equivalent:

LastMonth = WorksheetFunction.Text(Date - Day(Date), "[$-409]mmmm")

这篇关于VBA - 更改日期语言的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆