S
ste mac
Hi, the code below is as far as I have got (courtesy of this ng). I
asked a question similar
to this a few days ago, and with help have arrived to this point.
By testing it with msg box's it seems to be doing what it is supposed
to for the most part.
It is supposed to find the last occurence in the range on sheet
'BaseData' of a value =>
minValue and <=maxValue, and pass the row number the value was found on
to another
sheet named 'Main'. Thats it, all that is required is the row number of
the last occurence.
I am almost sure the code is stepping backwards through the range on
sheet 'BaseData' but
does not seem to start stepping backwards from 'LastRow' but from row
6!...gggaaaaaarrrrhhhhh.....
Can anybody see what I've done wrong? Have I gone the wrong way about
it?
cheers
ste
Sub aaa()
Application.ScreenUpdating = False
Dim DataRng As Range
Dim r As Integer
Dim LastRow As Long
Dim minValue As Long
Dim maxValue As Long
minValue = Sheets("Main").Range("I" & Rows.Count).End(xlUp).Value
maxValue = Sheets("Main").Range("J" & Rows.Count).End(xlUp).Value
LastRow = Sheets("BaseData").Cells(Rows.Count, "B").End(xlUp).Row
Set DataRng = Sheets("BaseData").Range("B2:U" & LastRow)
For r = LastRow To 2 Step -1
If DataRng(r) >= minValue And DataRng(r) <= maxValue Then
Sheets("Main").Range("L65536").End(xlUp).Offset(1, 0).Value
= r
End If
Next r
Application.ScreenUpdating = True
End Sub
asked a question similar
to this a few days ago, and with help have arrived to this point.
By testing it with msg box's it seems to be doing what it is supposed
to for the most part.
It is supposed to find the last occurence in the range on sheet
'BaseData' of a value =>
minValue and <=maxValue, and pass the row number the value was found on
to another
sheet named 'Main'. Thats it, all that is required is the row number of
the last occurence.
I am almost sure the code is stepping backwards through the range on
sheet 'BaseData' but
does not seem to start stepping backwards from 'LastRow' but from row
6!...gggaaaaaarrrrhhhhh.....
Can anybody see what I've done wrong? Have I gone the wrong way about
it?
cheers
ste
Sub aaa()
Application.ScreenUpdating = False
Dim DataRng As Range
Dim r As Integer
Dim LastRow As Long
Dim minValue As Long
Dim maxValue As Long
minValue = Sheets("Main").Range("I" & Rows.Count).End(xlUp).Value
maxValue = Sheets("Main").Range("J" & Rows.Count).End(xlUp).Value
LastRow = Sheets("BaseData").Cells(Rows.Count, "B").End(xlUp).Row
Set DataRng = Sheets("BaseData").Range("B2:U" & LastRow)
For r = LastRow To 2 Step -1
If DataRng(r) >= minValue And DataRng(r) <= maxValue Then
Sheets("Main").Range("L65536").End(xlUp).Offset(1, 0).Value
= r
End If
Next r
Application.ScreenUpdating = True
End Sub