Eric,
Code below may do the trick, provided I have understood you correctly
Function CellLet(ByVal st As String)
Dim i As Integer
Dim cellletter As String
For i = 1 To Len(st)
Select Case Asc(Mid(st, i, 1))
Case 65 To 90
cellletter = cellletter & Mid(st, i, 1)
Case 97 To 122
cellletter = cellletter & Mid(st, i, 1)
End Select
Next
CellLet = cellletter
End Function
Function CellNum(ByVal st As String)
Dim i As Integer
Dim cellnumber As Long
For i = 1 To Len(st)
Select Case Asc(Mid(st, i, 1))
Case 48 To 57
cellnumber = cellnumber & Mid(st, i, 1)
End Select
Next
CellNum = cellnumber
End Function
Sub Datacheck()
Dim cell As Range
Dim b As Boolean
Dim cNumber As Long
Dim cLetters As String
Dim myRows As Long
b = True
cNumber = CellNum(Cells(1, 2).Value)
cLetters = CellLet(Cells(1, 2).Value)
myRows = Range("A65536").End(xlUp).Row
For Each cell In Range(Cells(1, 1), Cells(myRows, 1))
If Not IsEmpty(cell) Then
If StrComp(cLetters, CellLet(cell), 1) <> 0 Then
b = False
End If
If cNumber - CellNum(cell) > 1000 Or CellNum(cell) - cNumber > 1000 Then
'change the above condition if required
b = False
End If
End If
Next
Cells(1, 3).Value = b
End Sub
|