Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default Find Largest Number "Again"

Referencing the "Find Largest Number" thread posted earlier this morning, I
redveloped the code to make it work better:

Sub TestAddendum()
Dim i As Long
Dim a As Integer
Dim row As Long
Dim Rng As Range
Dim LastRow As Long

LastRow = Range("A10000").End(xlUp).row

a = InputBox("EO#")
Set Rng = Columns(2).Find(a)
For row = 0 To LastRow
If Rng < 0 Then
MsgBox a & " " & Rng.Offset(row, 1)
End If
If Rng.Offset(row, 0) < a Then
MsgBox "All Done"
Exit Sub
End If
Next
End Sub


I can get it to do all that I need (initially of course) except that before
it "Exit Sub", it repeats the first entry. (example 28735 0 - 5, 28735 0,
exit sub)

28734 0
28735 0
28735 1
28735 2
28735 3
28735 4
28735 5
28736 0
28737 0


How can I stop this after largest number in offset(row,1)?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 279
Default Find Largest Number "Again"

If I understand your question;

just reverse the order inside the for loop to quit before writing


If Rng.Offset(row, 0) < a Then
MsgBox "All Done"
Exit Sub
End If
If Rng < 0 Then
MsgBox a & " " & Rng.Offset(row, 1)
End If


"asmenut" wrote:

Referencing the "Find Largest Number" thread posted earlier this morning, I
redveloped the code to make it work better:

Sub TestAddendum()
Dim i As Long
Dim a As Integer
Dim row As Long
Dim Rng As Range
Dim LastRow As Long

LastRow = Range("A10000").End(xlUp).row

a = InputBox("EO#")
Set Rng = Columns(2).Find(a)
For row = 0 To LastRow


Next
End Sub


I can get it to do all that I need (initially of course) except that before
it "Exit Sub", it repeats the first entry. (example 28735 0 - 5, 28735 0,
exit sub)

28734 0
28735 0
28735 1
28735 2
28735 3
28735 4
28735 5
28736 0
28737 0


How can I stop this after largest number in offset(row,1)?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default Find Largest Number "Again"

Thank you kindly for the response. I piddled around with it and realized I
was trying to make it more difficult than it had to be. The final code
(minus the Msgbox) is:

Sub TestAddendum()
Dim TempNo As Long
Dim a As Integer
Dim row As Long
Dim Rng As Range
Dim LastRow As Long
Dim i As Long
LastRow = Range("A10000").End(xlUp).row
a = InputBox("EO#")
Set Rng = Columns(2).Find(a)
For row = 0 To LastRow
If Rng.Offset(row, 0) = a Then
TempNo = Application.Max(Rng.Offset(row, 1))
MsgBox a & " " & TempNo
Else
MsgBox "All Done"
Exit Sub
End If
Next
End Sub

This will allow me to insert a row at the next addendum sequence and load
the data into the cells. (This should stop the "Sorting" procedure I
currently use when I use a "LastRow" Procedure). Should make the operation
quicker (until we have 1000 rows).. Thanks again.

"Vacation's Over" wrote:

If I understand your question;

just reverse the order inside the for loop to quit before writing


If Rng.Offset(row, 0) < a Then
MsgBox "All Done"
Exit Sub
End If
If Rng < 0 Then
MsgBox a & " " & Rng.Offset(row, 1)
End If


"asmenut" wrote:

Referencing the "Find Largest Number" thread posted earlier this morning, I
redveloped the code to make it work better:

Sub TestAddendum()
Dim i As Long
Dim a As Integer
Dim row As Long
Dim Rng As Range
Dim LastRow As Long

LastRow = Range("A10000").End(xlUp).row

a = InputBox("EO#")
Set Rng = Columns(2).Find(a)
For row = 0 To LastRow


Next
End Sub


I can get it to do all that I need (initially of course) except that before
it "Exit Sub", it repeats the first entry. (example 28735 0 - 5, 28735 0,
exit sub)

28734 0
28735 0
28735 1
28735 2
28735 3
28735 4
28735 5
28736 0
28737 0


How can I stop this after largest number in offset(row,1)?

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
How to find largest value "<=" when array is in descending order? [email protected] Excel Worksheet Functions 3 September 22nd 07 06:48 PM
Function to find 'n'th largest alphanumeric field (like "Large") Smibes Excel Worksheet Functions 8 June 17th 07 04:13 PM
find/replace "cr" from end of number to "-" in front of number Dave o Excel Discussion (Misc queries) 2 August 22nd 06 09:24 PM
HELP on "left","right","find","len","substitute" functions serene83 Excel Discussion (Misc queries) 5 June 27th 06 02:23 AM


All times are GMT +1. The time now is 10:04 PM.

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

About Us

"It's about Microsoft Excel"