如何在德语系统中用英文上月名称命名Excel工作表
I get it—when your system is stuck in German, all the default date formatting functions pull German month names instead of English. Let’s fix that with reliable solutions for both VBA and Excel formulas.
VBA Solution
The issue with your original VBA code is that Format() uses your system’s locale. Instead, use a hardcoded array of English month names to bypass this entirely:
Sub RenameSheetToEnglishPrevMonth() ' Calculate the number of the previous month (1-12) Dim prevMonthNum As Integer prevMonthNum = Month(DateAdd("M", -1, Now)) ' Array of English month names (indexes 0-11 match months 1-12) Dim englishMonths As Variant englishMonths = Array("January", "February", "March", "April", "May", "June", _ "July", "August", "September", "October", "November", "December") ' Rename the active sheet ActiveSheet.Name = englishMonths(prevMonthNum - 1) End Sub
This works every time because it doesn’t rely on system settings—we’re directly picking the correct name from our predefined list.
Excel Formula Solution
Your original CHOOSE() formula fails in January (since MONTH(TODAY())-1 becomes 0, which is invalid). Here’s a modified version that handles the January-to-December wrap-around:
=CHOOSE(MOD(MONTH(TODAY())-2,12)+1, "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December")
How it works:
MOD(MONTH(TODAY())-2,12)adjusts the month number to wrap around correctly (e.g., January → 11, February → 0)- Adding 1 shifts the result to the valid 1-12 range needed for
CHOOSE()
If you want to use this formula to set the sheet name via VBA, just reference the cell containing the formula:
ActiveSheet.Name = Range("A1").Value ' Replace A1 with your formula cell
内容的提问来源于stack exchange,提问作者Deepak

