The following code gives a warning message but the different string lengths of the registration numbers is offsetting longer values
Sub a1()
Dim LR As Long, i As Long, msg As String
With Sheets("TRUCK SERVICE")
Dim rCell As Range
Dim rRng As Range
Set rRng = Sheet1.Range("B3:b56")
'For Each rCell In rRng.Cells
'rCell.NumberFormat = "@"
'rCell.Value = myFormat(rCell.Value)
'Next rCell
LR = .Range("l" & Rows.Count).End(xlUp).Row
For i = 2 To LR
If IsDate(.Range("l" & i)) Then
If .Range("l" & i).Value - Date < 30 Then
msg = msg & vbTab & .Range("B" & i).Value & vbTab & "CVRT Expiry" & vbTab & Format(.Range("l" & i).Value, "dd/mm/yyyy") & vbCrLf
End If
End If
Next i
End With
If msg <> "" Then MsgBox prompt:=Left(msg, Len(msg) - 1), Title:="CVRT Expiry Warning", Buttons:=vbExclamation
End Sub
Public Function myFormat(str As String) As String
myFormat = Format(str, "!" & String(9, "@"))
End Function
I've tried quite a few methods, including the above function, but cant find the solution. Anyone any ideas?? Appreciated as its annoying
Bookmarks