T
tracktraining
Hi Everyone,
I have a column that contains serial numbers in this format - mmddyy - ###
(i.e. 060308-001).
I would like to split out the first 6 digits and convert it into a date
(mm/dd/yy).
I tried to do this with the following code and it doesn't work:
'------start code
startserial = Format(Me.Start_Serial, "mm/dd/yy")
endserial = Format(Me.End_Serial, "mm/dd/yy")
For Each SerialRng In SerialRng.cells
myserial = Left(SerialRng.cells(SerialRng.row, 4), 6)
record_serial = Format(myserial, "mm/dd/yy")
On Error Goto Next SerialRng ***(see note below)
If record_serial >= startserial And record_serial <= endserial Then
SerialRng.EntireRow.Copy
Sheets("Data").Select
cells(Rows.count, 1).End(xlUp)(2).Select
Selection.PasteSpecial Paste:=xlAll
End If
Next SerialRng
'---- end code
***here I would like for it to skip to the next SerialRng if cannot get the
first 6 digit to convert into a date - sometimes the field may not be a
serial number and just some other ID number so it can't be converted into a
date.
Please help if possible.
Thank you!
tracktraining
I have a column that contains serial numbers in this format - mmddyy - ###
(i.e. 060308-001).
I would like to split out the first 6 digits and convert it into a date
(mm/dd/yy).
I tried to do this with the following code and it doesn't work:
'------start code
startserial = Format(Me.Start_Serial, "mm/dd/yy")
endserial = Format(Me.End_Serial, "mm/dd/yy")
For Each SerialRng In SerialRng.cells
myserial = Left(SerialRng.cells(SerialRng.row, 4), 6)
record_serial = Format(myserial, "mm/dd/yy")
On Error Goto Next SerialRng ***(see note below)
If record_serial >= startserial And record_serial <= endserial Then
SerialRng.EntireRow.Copy
Sheets("Data").Select
cells(Rows.count, 1).End(xlUp)(2).Select
Selection.PasteSpecial Paste:=xlAll
End If
Next SerialRng
'---- end code
***here I would like for it to skip to the next SerialRng if cannot get the
first 6 digit to convert into a date - sometimes the field may not be a
serial number and just some other ID number so it can't be converted into a
date.
Please help if possible.
Thank you!
tracktraining