VBA search, copy, and paste data between worksheets

zJenkins

Board Regular
Joined
Jun 5, 2015
Messages
148
Hi,

I'm working on a payroll type project. Each month I download pay data from the internet into an excel worksheet, worksheet 1. Column A has the account number, Column B is the description, and Column C is the amount. I want to create a macro that goes through the account numbers in column A and checks whether or not there is a number in column C of the same row. If there is, then I want the amount to be pasted into worksheet 2. Worksheet 2 has a table, . There are times when an account has two amounts. When they are put into worksheet 2 they will go in the same cell so I'd like them added together.

Below is an example of both worksheets. The first row of each section in worksheet 1 is the department number and description. The first cell in each section has the department number followed by the account number (ie 0300-5110 is department 300 account 5110). From worksheet 1 I want cells C2 and C3 added together and pasted into worksheet 2 cell B2. Then also, there are double departments sometimes, so dept 0500 is made up of corporate A and B. I'd like those added together. For example, C8, C9, C14 and C15 all added together and pasted into cell C2 of worksheet 2

Worksheet 1

0300Finance
0300-5110Wages500
0300-5110Vacation200
0300-5455LTD100
0300-5411Parking
0500Corporate A
0500-5110Wages500
0500-5110Vacation80
0500-5455LTD120
0500-5450GST
0500Corporate B
0500-5110Wages250
0500-5110Vacation100
0500-5455LTD90
0500-5212Pension80

Worksheet 2

03000500
5110
5455
5411
5450
5212

Let me know if you need further clarification. Thanks for your input.
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.

Forum statistics

Threads
1,214,598
Messages
6,120,441
Members
448,966
Latest member
DannyC96

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