Help creating macro

  • Thread starter Thread starter Anonymous
  • Start date Start date
A

Anonymous

I need some help creating what is probably a very basic
macro but I'm over my head - help!

Here's what I'm trying to do:

I want the user to be prompted to enter a customer ID and
then automatically look up that ID (there are two
worksheets that it needs to look in) and retrieve the
entire corresponding row.

Any input would be appreciated. Thanks!
 
What do you mean by 'retrieve"? Show the values on a userform, enter them
into a set range of cells on a third worksheet, enter them into the bottom
row or a range of cells on a third worksheet, export them to a text file,
send them out in an e-mail attachment.....?

Be very specific, since computers are very dumb, and only do exactly what
you tell them.

HTH,
Bernie
MS Excel MVP
 
Thanks for the help!

I have two worksheets of data, the third worksheet is
where I want the macro - just a prompt for the user
to "Enter Customer ID" and then I want the corresponding
row (from one of the two other worksheets) to be entered
below the prompt on the third worksheet.

Am I making any sense? :)
 
Yes, you are making some limited amount of sense ;-)

You can use a simple macro like this to put the customer ID into a cell (in
this example D1) on your worksheet:

Sub GetCustID()
Worksheets("Sheet3").Range("D1").Value = Inputbox("What is the Customer
ID?")
End Sub

Then you can "pull" all the data that you want using VLOOKUP formulas linked
to the value in D1. For example, putting this in Cell A4 and copying to
Cell K4 will pull the first 11 columns out of Sheet2, A1:K20, where the data
matches D1:

=IF(ISERROR(VLOOKUP(D1,Sheet2!$A$1:$K$20,COLUMN(),FALSE)),"The Customer ID "
& D1 & " Doesn't exist",VLOOKUP(D1,Sheet2!$A$1:$K$20,COLUMN(),FALSE))

HTH,
Bernie
MS Excel MVP
 
Some limited amount of sense is pretty good for a
Friday. Oh, who am I kidding? It's pretty good for any
day!

Thanks a lot, I'll give this a whirl!
 
Back
Top