vba...finding location of number

  • Thread starter Thread starter chick-racer
  • Start date Start date
C

chick-racer

I would like to know if this is possible:

I have the code asking user for a number
The number input is compared to a range of values on a previous sheet
If the number is 'valid' then i would like to know if there is a wa
for me to find out what row the matched up value is in?
THANK YOU!

here is the incomplete code:

Sub commandbutton1_click()

Dim rng As Range
Dim roundNumber As Integer
Dim matchNumber As Variant

roundNumber = InputBox("Enter the Round number for which you would lik
the summary ", "Round Number")

Set rng = Worksheets(1).Range("C4:C12")

matchNumber = Application.Match(roundNumber, rng, 0)
If Not IsError(matchnumber) Then
'want to find what row the matched number is on sheet 1

Else
MsgBox "That is not a valid Round number"
End If

End Su
 
Try something like

If Not IsError(matchNumber) Then
MsgBox rng.Offset(matchNumber - 1, 1).Row
Else
MsgBox "That is not a valid Round number"
End If


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
Back
Top