I solved the related problem. My book is for use in the UK only. It has a sheet for entering information on cash collected at various sites. The user has two fields with one cell to identify each place; usually location and date, but sometimes the date field will contain the extended name of the place. Dates should be entered as dd / mm / yy, but almost all recognizable ones are accepted except mm / dd / yy. Parts are stored in memory and then copied to formatted worksheets for printing. I checked the memory in memory. But after the book was used for several months, I found that if the user entered a valid date in the cell in the format dd / mm / [yy] yy (for example, 05/11/17) and its interpretation as mm / dd / [yy] yy will also give a valid date, then the date will be obscurely printed as March 11th and not November 05th.
Some snippets of code:
'Data structure: Public Type BkItem 'An item of income, for banking. ItemName As String 'The first field, just a text name. ItemDate As Date 'The second field, interpreted as a date. ItemDateNumber As Long 'The date as internally stored as an integer. ItemDateString As String 'Re-formatted string, eg "05-Nov-17". ' ... End Type 'BkItem. 'Input validation: BankData = Range(.Cells(BankFirstRow, BankFirstCol), _ .Cells(BankLastItemLastRow, BankLastCol)) With BankItem(BankTotalItems) .ItemName = IName .ItemDateString = BankData(<row>, <col>) .ItemDateNumber = DateToLong(.ItemDateString) End With 'Utility routine. "Paper" is a 2-dimensional array of all the data to be printed 'on one or more pages; "Dest" is a global range.: Sub OutputDataToSheet(ByVal Size As Long, ByRef CurrentSheet As String, _ ByRef Paper() As Variant) Worksheets(CurrentSheet).Activate Set Dest = Worksheets(CurrentSheet).Range((Cells(1, 1)), _ (Cells(Size, LastCol))) Dest.Value = Paper 'Copy data to final sheet for printing. End Sub 'OutputDataToSheet. 'As we build the array "Paper", it helps to format those cells on the final 'printout worksheet which are going to contain dates. .Range(Cells(CurRow, L15c01), Cells(CurRow, L15c01)).NumberFormat = "dd-Mmm-yyyy" 'For the item date. .Range(Cells(CurRow, L15c01), Cells(CurRow, L15c01)).HorizontalAlignment = xlCenter If IsDate(BankItem(item).ItemDateString) Then Paper(<row>, <col>) = BankItem(item).ItemDateNumber 'Date as a number, so OutputDataToSheet preserves UK date format. Else Paper(<row>, <col>) = BankItem(item).ItemDateString 'Extension of name. End If 'IsDate(.ItemDateString).
source share