Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi
Can someone help with a macro doing the following? 1. Open an Inputbox (User then writes a number with four digits) 2. Search for the number in column A (from start to end. The number will will be present only once) 3. Go to the cell with the found number 4. If the number is not found a message box should pop up telling this. Thank you Kaj Pedersen |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Try...
Sub FindNumber() Dim NumToFind, rng As Range NumToFind = Application.InputBox("Enter the number to find", Type:=1) If NumToFind = False Then Beep: Exit Sub Set rng = Range("A:A").Find(NumToFind, LookIn:=xlValues) If rng Is Nothing Then MsgBox "The number was not found" Else ActiveWindow.ScrollRow = rng.Row End If End Sub -- Garry Free usenet access at http://www.eternal-september.org Classic VB Users Regroup! comp.lang.basic.visual.misc microsoft.public.vb.general.discussion |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi
Thank you for your suggestion that (almost) seems to work. Still, there is a little problem: Let's say I have the following numbers in column A 4444 404 43 4 If I carry out a search for the number "4" the macro goes to the first cell containing the digit "4" In this instance 4444 Can this issue be solved and also, is it possible to have the search result as active cell? Regards, Kaj Pedersen |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi
Thank you for your suggestion that (almost) seems to work. Still, there is a little problem: Let's say I have the following numbers in column A 4444 404 43 4 If I carry out a search for the number "4" the macro goes to the first cell containing the digit "4" In this instance 4444 Can this issue be solved and also, is it possible to have the search result as active cell? Regards, Kaj Pedersen Sub FindNumber() Dim NumToFind, rng As Range NumToFind = Application.InputBox("Enter the number to find", Type:=1) If NumToFind = False Then Beep: Exit Sub Set rng = Range("A:A").Find(NumToFind, LookIn:=xlValues, LookAt:=xlWhole) If rng Is Nothing Then MsgBox "The number was not found" Else ActiveWindow.ScrollRow = rng.Row End If End Sub -- Garry Free usenet access at http://www.eternal-september.org Classic VB Users Regroup! comp.lang.basic.visual.misc microsoft.public.vb.general.discussion |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thank you very much indeed.
Now only one wish is left. Is it possible to write the macro so that the cell that was searched for is selected when the macro has finished? I very much like the scroll to the top of the sheet (ActiveWindow.ScrollRow = rng.Row), so this must not be let out. Thank you. Best regards, Kaj Pedersen |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Ok...
Sub FindNumber() Dim NumToFind, rng As Range NumToFind = Application.InputBox("Enter the number to find", Type:=1) If NumToFind = False Then Beep: Exit Sub Set rng = Range("A:A").Find(NumToFind, LookIn:=xlValues, LookAt:=xlWhole) If rng Is Nothing Then MsgBox "The number was not found" Else ActiveWindow.ScrollRow = rng.Row: rng.Select End If End Sub -- Garry Free usenet access at http://www.eternal-september.org Classic VB Users Regroup! comp.lang.basic.visual.misc microsoft.public.vb.general.discussion |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Garry
You have now solved the problem to my full satisfaction. Once again, thank you. Kaj Pedersen |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Garry
You have now solved the problem to my full satisfaction. Once again, thank you. Kaj Pedersen Glad to help and I appreciate the feedback... -- Garry Free usenet access at http://www.eternal-september.org Classic VB Users Regroup! comp.lang.basic.visual.misc microsoft.public.vb.general.discussion |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Find empty cell and input data for other cells | Excel Programming | |||
How to add 'ft' to number input in cell - as in 25ft | Excel Discussion (Misc queries) | |||
Formatting to show 0 as first number in a cell when input | Excel Worksheet Functions | |||
how to input a 12 digit number into a cell | New Users to Excel | |||
making a cell fixed number to a input number | Excel Programming |