Find a number in a list.

Matt5353

Board Regular
Joined
Nov 30, 2018
Messages
60
Office Version
  1. 2016
Platform
  1. Windows
I have a list of numbers 0-8200. I can use the find function on the home tab but I wish to have a search box that will highlight the number selected but you have to scroll through the list to find it. Is there a way I can have a search box on my spreadsheet so when I type in the required number it will go straight to the number without scrolling through the long list of numbers?
Andrew
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
You could create a little VBA procedure like this, and attach it to a button:
VBA Code:
Sub MyFind()

    Dim x As Variant
    Dim rng As Range
    
'   Prompt user to enter value to look for
    x = InputBox("What value do you want to find?")
    
'   Search for value
    Set rng = Cells.Find(What:=x, After:=Range("A1"), LookIn:=xlFormulas2, LookAt:= _
        xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
        , SearchFormat:=False)
        
'   Go to range
    If rng Is Nothing Then
        MsgBox "Cannot find " & x & " on the active sheet", vbOKOnly, "VALUE NOT FOUND!"
    Else
'       Select range
        rng.Select
'       Highlight range
        rng.Interior.Color = 65535
    End If
    
End Sub
 
Upvote 0
You could create a little VBA procedure like this, and attach it to a button:
VBA Code:
Sub MyFind()

    Dim x As Variant
    Dim rng As Range
   
'   Prompt user to enter value to look for
    x = InputBox("What value do you want to find?")
   
'   Search for value
    Set rng = Cells.Find(What:=x, After:=Range("A1"), LookIn:=xlFormulas2, LookAt:= _
        xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
        , SearchFormat:=False)
       
'   Go to range
    If rng Is Nothing Then
        MsgBox "Cannot find " & x & " on the active sheet", vbOKOnly, "VALUE NOT FOUND!"
    Else
'       Select range
        rng.Select
'       Highlight range
        rng.Interior.Color = 65535
    End If
   
End Sub
So how does it actually work?
 
Upvote 0
What part don't you understand?

If you do not know how to add VBA code to your workbook, see here:

Then, if you do not know how to create a button and assign the VBA code to it, see here:
 
Upvote 0
I pasted in the macro and it works up to the inserted box. When I reference what I want an error box 400 appears!!
I am not sure what you mean. Can you post some screen images of your data and errors?
 
Upvote 0
Hope this is OK.
I put in a random number in the column and when I search it this box comes up
 
Upvote 0
I hope you can understand the Image I up loaded?
Thanks for the help
Andrew
 
Upvote 0
I do not see any image in your post.

You should be able to use copy and paste images in your posts like this:

1643228391062.png


Also, MrExcel has a tool called “XL2BB” that lets you post samples of your data that will allow us to copy/paste it to our Excel spreadsheets, so we can work with the same copy of data that you are. Instructions on using this tool can be found here: XL2BB Add-in

Note that there is also a "Test Here” forum on this board. This is a place where you can test using this tool (or any other posting techniques that you want to test) before trying to use those tools in your actual posts.
 
Upvote 0
I do not see any image in your post.

You should be able to use copy and paste images in your posts like this:

View attachment 56221

Also, MrExcel has a tool called “XL2BB” that lets you post samples of your data that will allow us to copy/paste it to our Excel spreadsheets, so we can work with the same copy of data that you are. Instructions on using this tool can be found here: XL2BB Add-in

Note that there is also a "Test Here” forum on this board. This is a place where you can test using this tool (or any other posting techniques that you want to test) before trying to use those tools in your actual posts.
I have the XL2bb. I have never used it. I had a look and how do I get to attach my files to it so you can have it. I could always email you directly with my file.
Andrew
 
Upvote 0

Forum statistics

Threads
1,214,385
Messages
6,119,208
Members
448,874
Latest member
b1step2far

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