#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default 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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default 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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Everthing worked fine and then....... tinknocker Excel Programming 2 November 11th 06 03:10 PM
1st copy prints fine, others do not CLR Excel Discussion (Misc queries) 2 October 26th 06 05:29 PM
Macro fine Run fine from Select but not from KB Shortcut? [email protected] Excel Discussion (Misc queries) 8 August 31st 06 02:06 AM
Works fine in debug, but... DiBaco Excel Programming 5 February 24th 06 04:35 PM
help w/ fine tuning Mike New Users to Excel 1 October 19th 05 08:58 PM


All times are GMT +1. The time now is 04:05 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"