Find a number within a range

ayazgreat

Well-known Member
Joined
Jan 19, 2008
Messages
1,151
Sir
I want to ask subject question , all I wanted to do is ask that can it be possible, we can find a number within a range through user form.

In a workbook ,having 4 or 5 sheets , diffrent ranges are scattered with their start range and end range like mentined below
Start Range End Range
2100100 2100199
2130100 2130199

If I want to search number like 2100125, then a user form finds it and goes to that cell containing searched number
 
Correction

Can you just change to
Rich (BB code):
x = Application.Match(myWhat, .Range("a:a"), 1)
 
Upvote 0

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Small problem ...
I type 11 and A2: B2 is highlighted (should be no such data}
 
Last edited:
Upvote 0
Ok then
try
Code:
Sub test()
Dim myWhat, x, y
myWhat = InputBox("what to search?")
If (myWhat = False) + (myWhat = "") Then Exit Sub
If IsNumeric(myWhat) Then myWhat = CDbl(myWhat)
With Sheets("sheet1")
    x = Application.Match(myWhat, .Range("a:a"), 1)
    y = Application.Match(myWhat, .Range("b:b"), 1)
    If Not IsError(x) Then
        If x <> y Then
            .Select
            .Range("a" & x).Resize(,2).Select
        Else
            MsgBox "No such data"
        End If
    Else
        MsgBox "No such data"
    End If
End With
End Sub
 
Upvote 0
Not yet with this last correction BUT maybe this will help:
I type 1 I get "type mismatch , same thing if I type 2 or 3 or 4 BUT if I type 5 I get No such data
 
Last edited:
Upvote 0
Hummm
try
change
Code:
    If Not IsError(x) Then
        If x <> y Then
            .Select
            .Range("a" & x).Resize(,2).Select
        Else
            MsgBox "No such data"
        End If
    Else
        MsgBox "No such data"
    End If
to
Code:
    If Not IsError(x) Then
        If Not IsError(y) Then
            If x <> y Then
                .Select
                .Range("a" & x).Resize(,2).Select
            Else
                MsgBox "No such data"
            End If
         Else
            .Select
            .Range("a" & x).Resize(,2).Select
         End If
    Else
        MsgBox "No such data"
    End If
 
Upvote 0
with this last correction it woks on all EXCEPT the number shown in column B (here number 5 and 10) get no such data ...
 
Upvote 0
I am truly sorry ... got confused. Pls disregard my last observation ... All works well WITH THANKS JINDON.
Regards, Nick
CORRECTION: PROBLEM AS NOTED IN LAST POST IS STILL ON ... does not work when I type 5 or 10 (the excat value in column B ... added more rows with same problem
 
Last edited:
Upvote 0

Forum statistics

Threads
1,217,377
Messages
6,136,201
Members
449,999
Latest member
sammokhan

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top