Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
vba...finding location of number
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 ----------------------------------------------- ~~ Message posted from http://www.ExcelTip.com ~~View and post usenet messages directly from http://www.ExcelForum.com |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
vba...finding location of number
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 "chick-racer" wrote in message ... 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 way 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 like 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 Sub ------------------------------------------------ ~~ Message posted from http://www.ExcelTip.com/ ~~View and post usenet messages directly from http://www.ExcelForum.com/ |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Finding a cell location | New Users to Excel | |||
Finding the Location within an Array | Excel Worksheet Functions | |||
Finding the location of what was summed | Excel Worksheet Functions | |||
Finding the location of MAX value in column | Excel Discussion (Misc queries) | |||
finding cell location | Excel Discussion (Misc queries) |