Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Finding last occurence of Interior.ColorIndex 36 | New Users to Excel | |||
Finding first occurence of a number | Excel Worksheet Functions | |||
Finding how many events since last occurence in a database list | Excel Worksheet Functions | |||
Finding most common occurence of values in cells containing letters and numbers | Excel Worksheet Functions | |||
Occurence #'s | Excel Discussion (Misc queries) |