Sub Main() Dim xCharArray() As Char = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".ToCharArray Dim xNoArray() As Char = "0123456789".ToCharArray Dim xGenerator As System.Random = New System.Random() Dim xStr As String = String.Empty While xStr.Length < 10 If xGenerator.Next(0, 2) = 0 Then xStr &= xCharArray(xGenerator.Next(0, xCharArray.Length)) Else xStr &= xNoArray(xGenerator.Next(0, xNoArray.Length)) End If End While MessageBox.Show(xStr, "New Number") ExcelFile = "C:\Users\Public\Documents\Autodesk\ARSCO Standards\iLogic\Random Part Number Generator.xlsx" i = GoExcel.FindRow(ExcelFile, "Sheet1", "Part Number", "=", xStr) If i = -1 Then MessageBox.Show("This number does not exist and is safe to add", "iLogic Notification") iProperties.Value("Custom", "Drawing Number") = Random GoExcel.CellValues(ExcelFile, "Sheet1", "A2", "") = Random ElseIf i > 1 Then MessageBox.Show("This number exists please generate a new number","iLogic Notification") End If End Sub