How JustAnswer Works:

  • Ask an Expert
    Experts are full of valuable knowledge and are ready to help with any question. Credentials confirmed by a Fortune 500 verification firm.
  • Get a Professional Answer
    Via email, text message, or notification as you wait on our site.
    Ask follow up questions if you need to.
  • 100% Satisfaction Guarantee
    Rate the answer you receive.

Ask The-PC-Guy Your Own Question

The-PC-Guy
The-PC-Guy, Computer Manager
Category: Microsoft Office
Satisfied Customers: 1844
Experience:  20 years experience providing remote computer support
62934938
Type Your Microsoft Office Question Here...
The-PC-Guy is online now
A new question is answered every 9 seconds

Need a macro to search a worksheet

This answer was rated:

Need a macro to search a worksheet with 2000 rows of employee data. Once it identifies employee by employee data I want it to copy multiple fields of data for that employee to a second worksheet located in a different workbook. Can someone tell me is this is possible. I tried and because it copies the exact cells, I can only run the macro once. If I run it a second time, it ignores new search criteria.

The-PC-Guy :

Thanks for using JustAnswer. My name isXXXXX will do whatever I can to answer your question

The-PC-Guy :

Yes this is possible

The-PC-Guy :

can you send me a copy of the workbook in question so I can see how your data is arranged.

The-PC-Guy :

you can upload your workbook to www.wikisend.com

The-PC-Guy :

after uploading they give you a file ID

The-PC-Guy :

paste that here.

The-PC-Guy :

Actaully if you want to copy from one sheet to another workbook, I will need a copy of both workbooks to be able to do this for you.

The-PC-Guy and 4 other Microsoft Office Specialists are ready to help you
The-PC-Guy :

Thanks for using JustAnswer. My name isXXXXX will do whatever I can to answer your question

The-PC-Guy :

Yes this is possible

The-PC-Guy :

can you send me a copy of the workbook in question so I can see how your data is arranged.

The-PC-Guy :

you can upload your workbook to www.wikisend.com

The-PC-Guy :

after uploading they give you a file ID

The-PC-Guy :

paste that here.

The-PC-Guy :

Actaully if you want to copy from one sheet to another workbook, I will need a copy of both workbooks to be able to do this for you

Customer: replied 3 years ago.

I am out at the moment will be home to upload in 45 minutes. Hope to have this by morning is that possible

shouldn't be a problem once I understand what you need.

Hopefully you will be a round after uploading to answer any clarifications I may need to help you.

But from my basic understanding.

You can a column of ID numbers

you want the macro to prompt for an ID number.

Then take whatever data is in any row that matches that ID number,

copy that row to another workbook,

then delete the original row?
Customer: replied 3 years ago.


I uploaded two workbooks:


 


One is a template where the data needs to be copied and pasted in yellow boxes. http://wikisend.com/download/135570/Template.xlsx


 


Two is the data file. http://wikisend.com/download/439368/ALPHA Report.xlsx


 


I want to start with opening the template and selecting a macro button that opens the data file. Once at the data file, I need an input or find box to pop up so that I can key in perno to search for an employee. Once It finds the employee row, I want to cut and paste the required fields to the template in the yellow boxes. The next time I need a new workbook for another employee, I want to open the Template (where macro resides) click on the button, key in the perno (input) and have it look up the employee in the data workbook and copy and paste it over the template.

so just to be clear on this

1. you are going to open the template file, and you want to click a button to run the macro which will be contained in the template file.

2. Then it will prompt you to select another workbook, this will contain the data. or will the data file always be the same, so it can be automatically opened?

3. Then you will be prompted for an ID number which is located in column B of the data file, we will then copy/concatenate the appropriate fields that are in yellow, over to the yellow boxes in the template file Sheet 1?

4. Then do we delete the row from the data file that we just copied, or do we leave it there?

Thanks
Customer: replied 3 years ago.

1. Yes open template to start process every time


2. Do not need a prompt, just automatically open file as it will always be the same name in the same location.


3. Yes, prompt to input or find ID number in column B. Copy/concatenate the appropriate fields from data workbook to template workbook. Example first name & last name will be concatenate to be copied to Employee Name Field. Salary will be copied over to salary field in yellow.


4. Good question. Once everything is copied to template workbook it will be saved out with a new name. The template is always empty so if user is going to use it again before closing, need a reset button to clean out fields. I know how to create reset macro and button.

ok

gotya.

i have this done for you.

http://wikisend.com/download/691838/Template.xlsm

 

also remember you will have to change the file name in the worksheet open to match where your file is located

let me know if you need any modifications

PLEASE REMEMBER TO RATE MY SERVICE

YOU DO SO WITH THE SMILEYS BENEATH THIS CHAT WINDOW

Customer: replied 3 years ago.

I will place macro in my workbooks and see if I can make work and
understand. Will review first thing in morning and see if I have any
questions. Thank you. Don't close my case just yet.

ok, I will be here if you need anything
Customer: replied 3 years ago.


This macro has done exactly what I want. You are Wonderful! SmileBefore I finalize and provide you with your rating. Have questions.


 


I transferred macro over to my real workbook which has personal data in it that is confidential. I replaced file names and locations and actual cells but once I input the perno, it is not working. I think it is because the sheets have real names and may not be necessarily in the sheet 1 placement in the workbook. Do I have to do something to convert the Sheet 1 to real tab name Input which is the first tab and Sheet 1 in the other workbook to DS which is really sheet 3?

that is correct, everywhere it refers to a sheet name, and I think there are about 4 or 5 spots. you would have to put the appropriate name. So for example

if you have something like

worksheets("Sheet 1").activate

you would change to

worksheets("Whatever your sheet name is").activate

remember that sheets are also specific to workbook.

I think i do a workbook.activate meathod a couple of times.

so where it says

workbooks("workbook name").activate

obviously that would refer to that workbook

and any

worksheets.activate functions following refer to that workbook

until you get to the next

workbooks.activate

then all sheets refer to that workbook.

hope this makes sense.

Let me know if you still get stuck.
did that help?

If you are still having trouble.

Could I remote into your computer and help you. You would be able to see everything I am doing.

Let me know.
Customer: replied 3 years ago.

I tried one more thing. If this doesn't work, I would appreciate your accessing my computer.


Placed in Wikisend:


 


These are the actual files. I had to remove a lot of confidential info, but I altered the macro to fit cells and filenames.


 


http://wikisend.com/download/548932/Banded Salary Promo Workup Tool.xlsm


 


http://wikisend.com/download/666234/Alpha for SAL Workup.xls

ok

first of all

this line

Workbooks("C:\Documents and Settings\chavispb\Desktop\SALWORKUP\Banded Salary Promo Workup Tool.xlsm").Activate

change it to just the file name, without the extension since this workbook is already open excel will find it as an object

so it should look like this

Workbooks("Banded Salary Promo Workup Tool").Activate

finally when you enter a number to search for, do not enter any leading 0000s

because the way excel evaluates it is as an integer and leading 00000s are automatically stripped off.

so if you are searching for 00054282 for example, you would enter that as 54282, and it will work.

if that gets confusing for the user you can change the cell format to general in column b of the


http://wikisend.com/download/666234/Alpha for SAL Workup.xls

 

file

 

and it will strip out all of the zeros that are displayed.

 

hope this helps.

 

if it still does not let me know and I will do the remote



whats the latest?

Did you finally get it to work?

If you are still struggling then let me do the remote and help you.

Anything I see will be kept confidential.

Let me know
Customer: replied 3 years ago.


It is working wonderfully. I just couldn't figure out how to respond back to you without this reply box. I want to provide you with an SmileEXCELLENT SERVICESmile Rating but I can't select the rating provided. Can you provide guidance for how I can provide feedback? I really appreciate all the work you did. Your understanding and patience, as well as your knowledge is incredible. I am so glad that I found you online. I would never have been able to complete this project without you. You are a star and have made me one as well.

Thanks

I will ask customer service to contact you to help with the rating process.

---------------------------------------------------------------------------------------------------------------

if you have any questions in the future you can visit my profile

http://www.justanswer.com/computer/expert-1expert-2rulethemall/

and ask a question right in my box,

also you can put "PC Guy only" in your question title if you want to get to me.

---------------------------------------------------------------------------------------------------------------

Let me know if that was unclear