LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Returning the row number of a cell in a range that matches a given condition

Any assistance would be welcomed and much appreciated! I use the code
below to attempt to return the row number of a cell that matches
certain conditions. I have tried several improvisations on the code,
but it fails to return the row number of the cell that matches the
conditions. As a check I have put in the message box, but the value of

the row number stays 0.


Private Sub btnSelect_Click()


Dim caseSelectNr As Long
Dim allCasesCell As Range
Dim allCasesRange As Range
Dim caseCell As Range
Dim rowNum As Long


caseSelectNr = Worksheets("Sheet2").Range("A2").Value


Set allCasesCell = Worksheets("Sheet1").Range("A10000").End(xlUp)
Set allCasesRange = Worksheets("Sheet1").Range("A2", allCasesCell)


On Error Resume Next
If Not allCasesRange Is Nothing Then
For Each caseCell In allCasesRange
If caseCell.Value = tbCaseSelect.Value Then
If caseCell.Value < caseCell.Offset(1, 0).Value Then
rowNum = caseCell.Row
End If
End If
Exit For
Next caseCell
End If


MsgBox rowNum


End Sub


Any help would be appreciated.
Regards,
Hennie

 
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
Returning Cell Value if Matches Another cell frankjh19701 Excel Worksheet Functions 5 February 13th 11 09:33 PM
returning a value in a cell if condition is met v1rt8 Excel Discussion (Misc queries) 3 September 14th 09 02:53 AM
Change fmt of a cell if number matches any in a range of cells? SteveR Excel Worksheet Functions 2 April 20th 06 05:32 PM
Returning the row number of a cell in a range that matches a given condition Hennie[_3_] Excel Programming 3 February 1st 06 10:43 AM
Returning a value for a number in a range Derek Excel Discussion (Misc queries) 1 July 26th 05 04:47 PM


All times are GMT +1. The time now is 05:46 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"