Match Inputbox Value on Values in Column

  • Thread starter Thread starter van
  • Start date Start date
V

van

I have an inputbox function, which requests a particular number (00 to 012)
from the user. I also have a column in excel which contains random numbers
in this range.

When the user enters a number I would like to be able to match this input to
the column of numbers, and extract those which match the input. Any ideas ?
 
00 is really a number. If you enter 00 and treat it as a number, then it
would be 0. So does your column Store numbers with formatting to show a
leading zero, or does you column contain Text.

one way

Sub FindCells()
Dim ans as String, cell as Range
Dim rng as Range
ans = InputBox("Enter value")
for each cell in Range("A1",Cells(rows.count,1).End(xlup))
if cell.Text = ans then
if rng is nothing then
set rng = cell
else
set rng = union(rng,cell)
end if
end if
Next
if not rng is nothing
rng.Select
End if
End Sub
 
Thanx Tom

The column stores numbers with a leading zero.
The code attached does not match up the list of numbers and copy them to a
separate location. Any ideas?

Thx
 
That code is pretty basic. If it doesn't work, it could be because you
haven't accurately described what is in the cell, what you enter has no
match, it is looking at the wrong location - any number of things. Assume
you have made modifications so it matches your situation. but as I said,
it is very simple and basic and slow - should work if a match can be made.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top