The Problem (Q-score 8, ranked #29th of 95 in the VBA Core archive)
The scenario as originally posted in 2012
I have a macro which I specify the date (in mm/dd/yyyy) in a textbox and I want to set this value for column A in yyyy-mm-dd format. I have the following code:
Sheets("Sheet1").Range("A2", "A50000").Value = TextBox3.Value
Sheet1.Range("A2", "A50000") = Format(Date, "yyyy-mm-dd")
…and when I run the macro, the date is still in mm/dd/yyyy format.
How can I change this so that it is in the format I want?? I’ve been trying many kinds of code researched through google and nothing will set the format the way I want it.
Any help will be appreciated…
EDIT: Full code from OP’s comment below:
Workbooks.Add
Range("A1") = "Acctdate"
Range("B1") = "Ledger"
Range("C1") = "CY"
Range("D1") = "BusinessUnit"
Range("E1") = "OperatingUnit"
Range("F1") = "LOB"
Range("G1") = "Account"
Range("H1") = "TreatyCode"
Range("I1") = "Amount"
Range("J1") = "TransactionCurrency"
Range("K1") = "USDEquivalentAmount"
Range("L1") = "KeyCol"
Sheets("Sheet1").Range("A2", "A50000").Value = TextBox3.Value
Sheet1.Range("A2", "A50000").NumberFormat = "yyyy-mm-dd"
Why this Range / Worksheet targeting trips people up
The question centers on reaching a specific cell, range, or workbook object. In VBA Core, this is the #1 source of failures after activation events: every property (.Value, .Formula, .Address) behaves differently depending on whether the parent Workbook is explicit or implicit.
The Verified Solution — strong answer (top 25 %%) (+18)
Verbal answer — walkthrough without a code block
Note: the verified answer is a prose walkthrough. If you need a runnable sample, check VBA Core entries ranked in the top 10 of the same archive.
Use the range’s NumberFormat property to force the format of the range like this:
Sheet1.Range("A2", "A50000").NumberFormat = "yyyy-mm-dd"
When to Use It — vintage (14+ years old, pre-2013)
Ranked #29th in its category — specialized fit
This pattern sits in the 85% tail relative to the top answer. Reach for it when your scenario closely matches the question title; otherwise browse the VBA Core archive for a higher-consensus alternative.
What changed between 2012 and 2026
The answer is 14 years old. The VBA Core object model has been stable across Office 2013, 2016, 2019, 2021, 365, and 2024/2026 LTSC, so the pattern still compiles. Changes that might affect you: 64-bit API declarations (use PtrSafe), blocked macros in downloaded files (Mark-of-the-Web), and the shift toward Office Scripts for web-first workflows.