ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   help.. want write a simple marco (https://www.excelbanter.com/excel-programming/295661-help-want-write-simple-marco.html)

dickychan

help.. want write a simple marco
 
l want write a simple marco to auto find a number in a long range o
number...like the following:
. A B
1 1 59
2 77 90
3 99 103
4 111 145
5 150 170
6 187 200

the value in A and B is mean from A to B.....like row 1..it mean
1, 2, 3, up to 59....and so on of other rows....
what l want is have a inputbox for me to input a value like
155....
and l need find in row 1's (A1: B1) ....then row'2 A and B ..until en
of row...
if the number what l input is in the those range...then msgbox show m
have this number....
Pls help...........th

--
Message posted from http://www.ExcelForum.com


Bernie Deitrick

help.. want write a simple marco
 
dickychan,

Try something like this, assuming your data starts in cell A1, and there is
nothing else in column A besides your table.

Sub FindNumberRow()
Dim myNum As Integer
myNum = Application.InputBox("What number?")
If myNum = Application.Min(Range("A:B")) And _
myNum <= Application.Max(Range("A:B")) Then
MsgBox "It's in row " & Application.Match( _
myNum, Range("A:A"))
Else
MsgBox "You picked a number out of my range!"
End If
End Sub

HTH,
Bernie
MS Excel MVP

"dickychan " wrote in message
...
l want write a simple marco to auto find a number in a long range of
number...like the following:
A B
1 1 59
2 77 90
3 99 103
4 111 145
5 150 170
6 187 200

the value in A and B is mean from A to B.....like row 1..it mean
1, 2, 3, up to 59....and so on of other rows....
what l want is have a inputbox for me to input a value like
155....
and l need find in row 1's (A1: B1) ....then row'2 A and B ..until end
of row...
if the number what l input is in the those range...then msgbox show me
have this number....
Pls help...........thx


---
Message posted from http://www.ExcelForum.com/




dickychan[_2_]

help.. want write a simple marco
 
thx very much....it solved my problem..thanka lot


---
Message posted from http://www.ExcelForum.com/



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

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