Macro for Copying Data

dejongt

New Member
Joined
Jun 26, 2019
Messages
2
Hello,

Looking for help creating a Macro to do the following:

Sheet 1: Employee Info
Sheet 2: Payment Prep
In Sheet 1 we input the employee information and assign theman Employee Info Index Number

I am looking for a Macro that will copy the data from theEmployee Info tab (which ranges from A2 to U2, B2 to U2, C2 to U2 etc.) to thePayment Prep worksheet when the applicable Employee Info Index Number isselected.
So for example if the following info is inputted in theEmployee Info sheet.
Employee Info Index #1 : John Smith

Employee Info Index #2 : Jane Doe
If I input Employee Info Index #1 on the Payment Prepworksheet all of the data from A2 to U2 on the Employee Info tab (relating to John Smith) will be copiedto the Payment Prep worksheet.

Any help is appreciated. Thanks

 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Re: Help with Macro for Copying Data

welcome to the forum :)

place code in Payment Prep SHEET module (does not work in standard module)

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Column > 1 Then Exit Sub
    On Error Resume Next
    Application.EnableEvents = False
    Sheets("Employee Info").Columns("A").Find(Target).Resize(, 21).Copy Target
    Application.EnableEvents = True
End Sub


When anything is entered in column A in Payment Prep the event macro
- looks for that value in Column A in sheet Employee Info
- and copies the values in columns A:U into sheet Payment Prep
- amend to suit your needs
 
Last edited:
Upvote 0
Re: Help with Macro for Copying Data

I have just looked at OP again
My suggested solution is not what you asked for :oops:
I will post a corrected version later
 
Upvote 0
Re: Help with Macro for Copying Data

In Sheet 1 we input the employee information and assign the man Employee Info Index Number
- this sounds like the Index Number is a unique number for each emloyee
- I assumed that is in column A and that is being used for the search

I am looking for a Macro that will copy the data from the Employee Info tab (
which ranges from A2 to U2, B2 to U2, C2 to U2 etc.) to thePayment Prep worksheet when the applicable Employee Info Index Number is selected

:confused: Is your data in rows (one for each employee) like this A2:U2, A3:U3, A4:U4 etc

Have a look at my solution (post#2) which is illustrated below & let me know if I misinterpreted what you want (include details)

thnaks

My original solution assumes data like this

Excel 2016 (Windows) 32 bit
A
B
C
D
E
F
G
H
I
J
1
Index NoName1SurnameInfo_4Info_5Info_6Info_7Info_8Info_9Info_10
2
0001
JohnSmithJS_4JS_5JS_6JS_7JS_8JS_9JS_10
3
0002
JaneDoeJD_4JD_5JD_6JD_7JD_8JD_9JD_10
4
0003
5
etc
Sheet: Employee Info

and returns this when index number is entered in any cell in column A


Excel 2016 (Windows) 32 bit
A
B
C
D
E
F
G
H
I
J
1
Index NoName1SurnameInfo_4Info_5Info_6Info_7Info_8Info_9etc ..columns J:U
2
0002
JaneDoeJD_4JD_5JD_6JD_7JD_8JD_9etc..
Sheet: Payment Prep




 
Upvote 0
Re: Help with Macro for Copying Data

Excellent - the code is in post#2
 
Upvote 0

Forum statistics

Threads
1,214,648
Messages
6,120,726
Members
448,987
Latest member
marion_davis

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top