Copy multiples of a single row (based on a cell value) into another worksheet when cell value changes

jehanim009

New Member
Joined
Jan 8, 2015
Messages
4
Hello, I'm new to creating macro codes and I mostly use solutions from this forum to form the code I need. However, I have not found a coding that satisfies my exact purpose; therefore, I decided to form my own question for once. Thanks in advance to whoever who replies.

Problem:
The code is supposed to copy a row in “Sheet 1” into “Sheet 2”, multiple times based on the cell value of column F (“# Employees”) in "Sheet 1" when the cell value changes.

Note: Only the row in which the cell value is changed should be copied into the next sheet (i.e. when a new row is added into "Sheet 1", ONLY this new row should be copied multiple times into "Sheet 2" when the "# Employees" for this row is added.)

Example:


[TABLE="width: 669"]
<colgroup><col><col><col><col><col><col><col></colgroup><tbody>[TR]
[TD="align: center"]A[/TD]
[TD="align: center"]B[/TD]
[TD="align: center"]C[/TD]
[TD="align: center"]D[/TD]
[TD="align: center"]E[/TD]
[TD="align: center"]F[/TD]
[TD="align: center"]G[/TD]
[/TR]
[TR]
[TD]Sheet 1:[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="align: center"]No.[/TD]
[TD="align: center"]Employee No.[/TD]
[TD="align: center"]EPF No.[/TD]
[TD="align: center"]Date[/TD]
[TD="align: center"]Salary[/TD]
[TD="align: center"]# Employees[/TD]
[TD="align: center"]Total Salary[/TD]
[/TR]
[TR]
[TD="align: center"]1[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"]15-Dec[/TD]
[TD="align: center"]7000.00[/TD]
[TD="align: center"]2[/TD]
[TD="align: center"]14000.00[/TD]
[/TR]
[TR]
[TD="align: center"]2[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"]16-Dec[/TD]
[TD="align: center"]8000.00[/TD]
[TD="align: center"]3[/TD]
[TD="align: center"]24000.00[/TD]
[/TR]
[TR]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]Sheet 2:[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]No.[/TD]
[TD="align: center"]Employee No.[/TD]
[TD="align: center"]EPF No.[/TD]
[TD="align: center"]Date[/TD]
[TD="align: center"]Salary[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]1[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"]15-Dec[/TD]
[TD="align: center"]7000.00[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]1[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"]15-Dec[/TD]
[TD="align: center"]7000.00[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]2[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"]16-Dec[/TD]
[TD="align: center"]8000.00[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]2[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"]16-Dec[/TD]
[TD="align: center"]8000.00[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]2[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"]16-Dec[/TD]
[TD="align: center"]8000.00[/TD]
[TD="align: center"][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!

Forum statistics

Threads
1,223,234
Messages
6,170,891
Members
452,366
Latest member
TePunaBloke

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