Try:-
Sub MG28Apr44
Dim Rng As Range, Dn As Range, n As Long, Num As String, nNum As Long, ac As Long, Rw As Long
Set Rng = Range(Range("A1"), Range("A" & Rows.Count).End(xlUp))
With CreateObject("scripting.dictionary")
.CompareMode = vbTextCompare
For Rw = 1 To 5000
ac = 0
For n = 1 To 98
Num = Format(n, "00")
If Not Right(Num, 1) = Left(Num, 1) Then
        .Item(n) = Num
End If
Next
    Do Until ac = 40
        nNum = Application.RandBetween(1, 98)
        If .exists(nNum) Then
            ac = ac + 1
            Cells(Rw, ac).NumberFormat = "@"
            Cells(Rw, ac) = .Item(nNum)
            .Remove nNum
        End If
    Loop
Next Rw
End With

End Sub
Regards Mick