Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Try this
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 Exit For End If End If Next caseCell End If MsgBox rowNum End Sub -- HTH Bob Phillips (remove nothere from email address if mailing direct) "Hennie" wrote in message oups.com... 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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks Bob, It works like a charm! Just a bit of logic, isn't it?
|
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Isn't it always <G?
-- HTH Bob Phillips (remove nothere from email address if mailing direct) "Hennie" wrote in message oups.com... Thanks Bob, It works like a charm! Just a bit of logic, isn't it? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Returning Cell Value if Matches Another cell | Excel Worksheet Functions | |||
returning a value in a cell if condition is met | Excel Discussion (Misc queries) | |||
number range returning a text value | New Users to Excel | |||
Change fmt of a cell if number matches any in a range of cells? | Excel Worksheet Functions | |||
Returning a value for a number in a range | Excel Discussion (Misc queries) |