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]
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]