Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 ? |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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" wrote in message ... 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 ? |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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" wrote in message ... 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" wrote in message ... 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 ? |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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. -- Regards, Tom Ogilvy "van" wrote in message ... 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" wrote in message ... 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" wrote in message ... 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 ? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Match values in more than one column | Excel Worksheet Functions | |||
If two criteria match then sum matching values in another column | Excel Worksheet Functions | |||
match values in two column and return value in | Excel Worksheet Functions | |||
MATCH A NUMBER AS THE SUM OF VALUES IN A COLUMN | Excel Worksheet Functions | |||
How to match values in one column to values in another? | Excel Worksheet Functions |