![]() |
Match Inputbox Value on Values in Column
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 ? |
Match Inputbox Value on Values in Column
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 ? |
Match Inputbox Value on Values in Column
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 ? |
Match Inputbox Value on Values in Column
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 ? |
All times are GMT +1. The time now is 07:18 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com