View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Olamide Olamide is offline
external usenet poster
 
Posts: 10
Default loop to check cells for numbers between 2 number range

Tom,
this is complex. i cannot even interpret it.
Sipe Olamide
Lagos, Nigeria

"Tom Ogilvy" wrote:

What if 89001/43 isn't there. I thought that was you problem

Sub AABBCC()
Dim l As String, r As String
Dim cell As Range, rng As Range
Dim bfirst As Boolean, bLast As Boolean
Dim cell1 As Range, cell2 As Range
For Each cell In Range("A1", Cells(Rows.Count, 1).End(xlUp))
If Len(cell.Value) 4 Then
If InStr(cell.Value, "/") Then
l = Left(cell.Value, 5)
r = Right(cell.Value, Len(cell.Value) - _
InStr(1, cell.Value, vbTextCompare) - 1)
If l = "89001" And CLng(r) = 43 And Not bfirst _
And Not bLast Then
Set cell1 = cell
bfirst = True
End If
' check for /xx 90
If l = "89001" And CLng(r) 90 And bfirst Then
Set cell2 = cell.Offset(-1, 0)
bLast = True
Exit For
End If
' check for 89001/
If l "89001" And bfirst And Not bLast Then
Set cell2 = cell.Offset(-1, 0)
bLast = True
Exit For
End If
Else
If l "89001" And bfirst And Not bLast Then
Set cell2 = cell.Offset(-1, 0)
bLast = True
Exit For
End If
End If
End If
Next cell
Range(cell1, cell2).Select
End Sub
Next cell

should select the range of 89001/43 to 89001/90 inclusive assuming the data
is sorted to support this.

--
Regards,
Tom Ogilvy


"Olamide" wrote:

what of if i want to find range of 89001/43 to 89001/90 and select cell that
contain the first number within the range. can the quote still work in this.

"Olamide" wrote:

i have a code like this

Columns("A:A").Select ' Find Other Bank and Cash
On Error Resume Next
Selection.Find(What:="89001/43", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Select
If ActiveCell < 89001/43 Then
Range("A1").Select
Do While Selection < 89000 Or Selection 89176
Selection.Offset(1, 0).Select
Loop
End If

my problem is that the slash is alway converted to division. Can somebody
pls help me.

thanks