Insert row after duplicates in a column, sum values in a seperate column, delete values in first column (sounds easy, right?)

iamconstance

New Member
Joined
Nov 12, 2013
Messages
5
Employee number
Employee name
Project
Hours
12345
John Smith
ABC
3
12345
John Smith
ABC
10
12345
John Smith
ABC
12

<tbody>
</tbody>
Hi All.

Hoping someone who knows VBA can help me out.

I have a spreadsheet that pulls employee staff numbers and the amount of hours they worked each week. The issue is that some employees may have worked on more than one project each week.

What I need to do is write some VBA that will identify the employee numbers that are duplicated (or triplicated, etc.), insert a row below them, copy the employee number and sum the total hours worked. I then want the duplicated (or triplicated, etc) employee numbers deleted so that I can do a vlookup and only pull back the total hours worked.

Example above

Any help is GREATLY APPRECIATED
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Are these values already sorted so all duplicates will appear in succession?
Is your data really structured as shown above, and is it in columns A-D?
Does your data start on row 2, and is there anything after the last row of data (any sort of totals or other data)?
 
Upvote 0
1. I can sort the data so that it appears in succession, by sorting by employee number.
2. No, it's not exactly as above, there are columns in between, but I can figure out how to delete or discard those I don't need
3. Yes, data starts on row 2, and I can remove any subtotal rows.
 
Upvote 0

Forum statistics

Threads
1,215,767
Messages
6,126,774
Members
449,336
Latest member
p17tootie

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