Re: Match Inputbox Value on Values in Column

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: van (a_at_fred.com)
Date: 02/22/05


Date: Tue, 22 Feb 2005 13:52:31 -0000

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

"Tom Ogilvy" <twogilvy@msn.com> wrote in message
news:OWc2e0DGFHA.1740@TK2MSFTNGP09.phx.gbl...
> 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
>
>
>
>
> --
> Regards,
> Tom Ogilvy
>
> "van" <a@fred.com> wrote in message
> news:%23Kzd5WDGFHA.1260@TK2MSFTNGP12.phx.gbl...
> > 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
> ?
> >
> >
>
>


Quantcast