Ark68
Well-known Member
- Joined
- Mar 23, 2004
- Messages
- 4,564
- Office Version
- 365
- 2016
- Platform
- Windows
I have this code ....
In the std loop, i get the value of variable 'vl' from my data source. It is gathered from column 1 in each of the rows of the loop ('std')
The values in column 1 of the source worksheet (ws-rmr1) are text representations of dates, and take on this format "Jul 10, 2023"
The line in green converts that text date to a true date.
The following green line is supposed to give the dates a format of dd/mmm/yyyy. But it's not. Why is my result 10-07-2023? The date is correct, just the the format I expected (10/Jul/2023).
Rich (BB code):
With ws_rmr1
cntrmr1raw = .Range("A" & .Rows.Count).End(xlUp).Row - 1
If cntrmr1raw < 1 Then
uf_caption = "RMR1 EMPTY"
lb_msg1 = "rmr1.xlsx is empty of any records." & Chr(13) & "Access ActiveNet to recreate the file or [NOT NOW] to cancel."
Else
'create unique date list
ws_thold.Columns("A:D").Clear
drow = 1
For std = 2 To cntrmr1raw + 1
vl = .Cells(std, 1)
.Cells(std, 1) = DateValue(vl)
.Columns("A:A").NumberFormat = "dd/mmm/yyyy"
If Application.WorksheetFunction.CountIf(ws_thold.Columns(1), vl) < 1 Then 'add to the list
ws_thold.Cells(drow, 1) = vl 'text date
ws_thold.Cells(drow, 2) = Format(DateValue(vl), "dddd dd-mmm") 'true date conversion
drow = drow + 1 'advance destination row for next unique date value
End If
Next std
End If
End With
In the std loop, i get the value of variable 'vl' from my data source. It is gathered from column 1 in each of the rows of the loop ('std')
The values in column 1 of the source worksheet (ws-rmr1) are text representations of dates, and take on this format "Jul 10, 2023"
The line in green converts that text date to a true date.
The following green line is supposed to give the dates a format of dd/mmm/yyyy. But it's not. Why is my result 10-07-2023? The date is correct, just the the format I expected (10/Jul/2023).