在Excel中维护date格式

我有一个三个combobox的表格,一个用于(可能的)31个月,第二个用12个数字表示月份,第三个用相当于未来五年的年份值。

我连接在一起形成一个date

TheDay = CBDay.Value TheMonth = CBMonth.Value TheYear = CBYear.Value thedate = TheDay + "/" + TheMonth + "/" + TheYear 

所以,在澳大利亚今天的date将显示为10/12/2015,这工作正常。 但是,当我将数据写入工作表时,即使将写入数据的列格式设置为“dd / mm / yy”样式的“date”,date也会持续转换为2015年12月10日

variables被声明为整数

有没有办法确保date的价值不变?

Excel认为格式化看起来像date的string很聪明。

只要有可能,请使用date序列号并强制您自己的格式

例如

 Dim theDate As Date theDate = DateSerial(TheYear, TheMonth, TheDay) ActiveCell = theDate ActiveCell.NumberFormat = "dd/mm/yyyy" ' or better yet, use an unambiguous date format ActiveCell.NumberFormat = "dd mmm, yyyy"