ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   vba...finding location of number (https://www.excelbanter.com/excel-programming/283661-vba-finding-location-number.html)

chick-racer[_42_]

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


Chip Pearson[_2_]

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/





All times are GMT +1. The time now is 09:11 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com