Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default 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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default 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

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default 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



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default 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

  #7   Report Post  
Posted to microsoft.public.excel.programming
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

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default 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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Check number within a range djungst Excel Worksheet Functions 2 September 3rd 08 08:45 PM
loop through cells in a range and pick up corresponding cell values in another range [email protected] Excel Programming 9 October 19th 06 05:11 AM
How do I check repeating sets of number in a range Tshidiso Excel Worksheet Functions 1 September 2nd 05 11:02 AM
Check if a number exists in a range? gkaste Excel Discussion (Misc queries) 2 July 13th 05 08:00 PM
Create a Loop to check cells between workbooks No Name Excel Programming 0 September 16th 04 04:35 PM


All times are GMT +1. The time now is 07:50 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"