ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   loop to check cells for numbers between 2 number range (https://www.excelbanter.com/excel-programming/384130-loop-check-cells-numbers-between-2-number-range.html)

Olamide

loop to check cells for numbers between 2 number range
 
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

Tom Ogilvy

loop to check cells for numbers between 2 number range
 
If ActiveCell < "89001/43"

--
regards,
Tom Ogilvy

"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


Olamide

loop to check cells for numbers between 2 number range
 
Tom the "Do While Selection < 89000 Or Selection 89176" will not work if
selection 89001/43

"Tom Ogilvy" wrote:

If ActiveCell < "89001/43"

--
regards,
Tom Ogilvy

"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


Don Guillett

loop to check cells for numbers between 2 number range
 
What are you trying to do?

Sub findtext1()' finds this text
Columns("a").Find("89001/43").Select
End Sub

--
Don Guillett
SalesAid Software

"Olamide" wrote in message
...
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




Olamide

loop to check cells for numbers between 2 number range
 
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


Tom Ogilvy

loop to check cells for numbers between 2 number range
 
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


Olamide

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


Tom Ogilvy

loop to check cells for numbers between 2 number range
 
there is a typo in it anyway.

r = Right(cell.Value, Len(cell.Value) - _
InStr(1, cell.Value, vbTextCompare))

should be

r = Right(cell.Value, Len(cell.Value) - _
InStr(1, cell.Value, "/", vbTextCompare))


but now you should see why I don't spend a lot of time writing code for you
- it would never get used.
--
Regards,
Tom Ogilvy


"Olamide" wrote:

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



All times are GMT +1. The time now is 12:01 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com