Experts Exchange connects you with the people and services you need so you can get back to work.
MsgBox (getRow(ActiveSheet.Range("B2:C5"), 2, 5))
MsgBox (getRow(ActiveSheet.Range("B2:C5"), 2, 10))
Function getRow(rng As Range, theColumn as Long, theValue As Variant)
Dim r As Long
getRow = -1
For r = 1 To rng.Rows.Count
If rng.Cells(r, theColumn).Value = theValue Then
' Choose only one of the following assignments depending on what you want
' If you want the row with the range
getRow = r
' if you want the absolute row number in the worksheet
getRow = r + rng.Cells(1, 1).Row - 1
Open in new window
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Range("A2"), Target) Is Nothing Then
ActiveSheet.Range("A4").Value = ActiveSheet.Columns("B:B").Find(Range("A2").Value).Row
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
Please enter a first name
Please enter a last name
Must be at least 4 characters long.
Join and Comment
Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.