ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Fine (https://www.excelbanter.com/excel-programming/398005-fine.html)

Donald E

Fine
 
I need a macro, with a in put box for a number and find the number in column
A .
bring number to the top of sheet.


Thanks , need need help

Donald E
PS E-mail me with the code

JLGWhiz

Fine
 
This is untested, but should work, if the number is in column A.

Sub fndNbr()
lr = Cells(Rows.Count, 1).End(xlUp).Row
srchNbr = InputBox("Enter a number", "Number")
With ActiveSheet.Range("A2:A" & lr)
Set c = .Find(srchNbr, LookIn:xlValues)
If Not c Is Nothing Then
Range("A1") = c
End If
End With
End Sub

"Donald E" wrote:

I need a macro, with a in put box for a number and find the number in column
A .
bring number to the top of sheet.


Thanks , need need help

Donald E
PS E-mail me with the code


OssieMac

Fine
 
Hi donald,

I prepared and answer and I now see someone else has answered. However, I'll
post my code anyway because it is a variation on the other answer. This code
cuts the number from the original location and inserts it at the top. It also
allows you to continue your searches until you click cancel.

Sub Macro1()
Dim inputNumber As Variant
Dim foundCell As Range

Do
inputNumber = InputBox("Enter the number to be found" & _
Chr(13) & "Cancel to exit")

With Sheets("Sheet1").Columns("A")
Set foundCell = .Find(What:=inputNumber, _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByColumns, _
SearchDirection:=xlNext, _
MatchCase:=False, _
SearchFormat:=False)
If foundCell.Value < "" Then
foundCell.Cut
.Cells(1, 1).Insert Shift:=xlDown
End If
End With
Loop While inputNumber < ""

End Sub

Regards,

OssieMac




All times are GMT +1. The time now is 03:35 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com