Macro help

Closed
Annie - Jun 22, 2010 at 05:27 AM
venkat1926 Posts 1863 Registration date Sunday June 14, 2009 Status Contributor Last seen August 7, 2021 - Jun 22, 2010 at 05:57 AM
Hello,
I'm very, very new to vba. I have 2 worksheets. Sheet one has a long list of invoices and details. In sheet two I would like to have a user input an invoice number into an input box and then to copy that invoice into sheet two. I would also like two other message boxes to appear if 1) The input is not numeric or 2) The invoice is not found.I have managed some of it but when I try adding anything else I get errors. I know that it's my complete lack of understanding of vba but I would appreciate some help.
Here's what I've got:

Sub FindRecord()
'Beginning of the macro

Dim smallnumber As Integer
'Declare the variable smallnumber as an integer
Dim foundit As Object
'Create object variable

userinput = InputBox("Please enter an Invoice Number", "To Retrieve Invoice Details")
'This creates an input box and assigns the user input from the box to the variable mynumber

If IsNumeric(userinput) Then smallnumber = userinput Else MsgBox ("Your entry is invalid. Please try again.")
'This checks to see if the user input is a number & assigns the value to the variable smallnumber


With Sheets("sheet1").Cells

thingtolookfor = smallnumber
Set foundit = .Find(thingtolookfor, LookIn:=xlValues, Lookat:=xlWhole)
foundit.EntireRow.Copy
Worksheets("sheet2").Select
Range("A2").PasteSpecial



End With

End Sub


1 response

venkat1926 Posts 1863 Registration date Sunday June 14, 2009 Status Contributor Last seen August 7, 2021 811
Jun 22, 2010 at 05:57 AM
why is mcro necesary. you can use vlookup function in the second sheet.
if hte invoice is not available atomatically you will get #N/A result.

think on those lines.
0