Hello everyone!
I have a VBA question on how to create a macro that will copy/paste names to specific worksheets if conditions are met.
I get new data each month so this will be very helpful for me if it's automated.
The data is 91 rows (90 reports) so this is just an example.
The idea is that I click each row whether it is "Yes" or "No" (column B) then click RUN Macro button.
[TABLE="width: 784"]
<tbody>[TR]
[TD][/TD]
[TD]A
[/TD]
[TD]B
[/TD]
[TD]C
[/TD]
[TD]D
[/TD]
[TD]E
[/TD]
[TD]F
[/TD]
[TD]G
[/TD]
[TD]H
[/TD]
[TD]I
[/TD]
[/TR]
[TR]
[TD]1
[/TD]
[TD]Report#
[/TD]
[TD]Create
[/TD]
[TD]Include
[/TD]
[TD]Exclude
[/TD]
[TD]Name_Inc_1
[/TD]
[TD]Name_Inc_2
[/TD]
[TD]Name_Inc_3
[/TD]
[TD]Name_Exc_1
[/TD]
[TD]Name_Exc_2
[/TD]
[/TR]
[TR]
[TD]2
[/TD]
[TD]Report_1
[/TD]
[TD]Yes
[/TD]
[TD]1
[/TD]
[TD]1
[/TD]
[TD]Name_11
[/TD]
[TD][/TD]
[TD][/TD]
[TD]Name_41
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]3
[/TD]
[TD]Report_2
[/TD]
[TD]No
[/TD]
[TD]1
[/TD]
[TD]0
[/TD]
[TD]Name_12
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]4
[/TD]
[TD]Report_3
[/TD]
[TD]Yes
[/TD]
[TD]2
[/TD]
[TD]0
[/TD]
[TD]Name_13
[/TD]
[TD]Name_21
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]5
[/TD]
[TD]Report_4
[/TD]
[TD]Yes
[/TD]
[TD]3
[/TD]
[TD]2
[/TD]
[TD]Name_14
[/TD]
[TD]Name_22
[/TD]
[TD]Name_31
[/TD]
[TD]Name_42
[/TD]
[TD]Name_51
[/TD]
[/TR]
</tbody>[/TABLE]
- At B2, if Create column reads Yes then go to C2.
If C2 includes numeric value between 1-3 then copy/paste name from column Name_Inc_1 (for this instance, copy/paste Name_11) into cell A1 on worksheet Sheet_Inc_1.
At D2 (Exclude column), if numeric value is between 1-2 then copy/paste name from column Name_Exc_1 (for this instance, copy/paste Name_41) into cell A1 on
worksheet Sheet_Exc_1.
Save workbook to desktop as Report_1. Clear sheets then continue to next row...
- At B3, Create column reads No. Therefore, go to next row.
No saving workbook. No need to clear sheets (they are already cleared).
- At B4, if Create column reads Yes then go to C4. If C4 includes numeric value between 1-3 then copy/paste name from column Name_Inc_1 (for this instance, copy/paste Name_13) into cell A1 on worksheet Sheet_Inc_1.
Since B4's numeric value is 2, copy/paste twice. Copy/paste name from column Name_Inc_2 (Name_21) into cell A1 on worksheet Sheet_Inc_2.
Save workbook to desktop as Report_2. Clear sheets then continue to next row...
Reports 1-3 are completed. Macro should finish 90 reports.
Thanks for your help!
I have a VBA question on how to create a macro that will copy/paste names to specific worksheets if conditions are met.
I get new data each month so this will be very helpful for me if it's automated.
The data is 91 rows (90 reports) so this is just an example.
The idea is that I click each row whether it is "Yes" or "No" (column B) then click RUN Macro button.
[TABLE="width: 784"]
<tbody>[TR]
[TD][/TD]
[TD]A
[/TD]
[TD]B
[/TD]
[TD]C
[/TD]
[TD]D
[/TD]
[TD]E
[/TD]
[TD]F
[/TD]
[TD]G
[/TD]
[TD]H
[/TD]
[TD]I
[/TD]
[/TR]
[TR]
[TD]1
[/TD]
[TD]Report#
[/TD]
[TD]Create
[/TD]
[TD]Include
[/TD]
[TD]Exclude
[/TD]
[TD]Name_Inc_1
[/TD]
[TD]Name_Inc_2
[/TD]
[TD]Name_Inc_3
[/TD]
[TD]Name_Exc_1
[/TD]
[TD]Name_Exc_2
[/TD]
[/TR]
[TR]
[TD]2
[/TD]
[TD]Report_1
[/TD]
[TD]Yes
[/TD]
[TD]1
[/TD]
[TD]1
[/TD]
[TD]Name_11
[/TD]
[TD][/TD]
[TD][/TD]
[TD]Name_41
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]3
[/TD]
[TD]Report_2
[/TD]
[TD]No
[/TD]
[TD]1
[/TD]
[TD]0
[/TD]
[TD]Name_12
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]4
[/TD]
[TD]Report_3
[/TD]
[TD]Yes
[/TD]
[TD]2
[/TD]
[TD]0
[/TD]
[TD]Name_13
[/TD]
[TD]Name_21
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]5
[/TD]
[TD]Report_4
[/TD]
[TD]Yes
[/TD]
[TD]3
[/TD]
[TD]2
[/TD]
[TD]Name_14
[/TD]
[TD]Name_22
[/TD]
[TD]Name_31
[/TD]
[TD]Name_42
[/TD]
[TD]Name_51
[/TD]
[/TR]
</tbody>[/TABLE]
- At B2, if Create column reads Yes then go to C2.
If C2 includes numeric value between 1-3 then copy/paste name from column Name_Inc_1 (for this instance, copy/paste Name_11) into cell A1 on worksheet Sheet_Inc_1.
At D2 (Exclude column), if numeric value is between 1-2 then copy/paste name from column Name_Exc_1 (for this instance, copy/paste Name_41) into cell A1 on
worksheet Sheet_Exc_1.
Save workbook to desktop as Report_1. Clear sheets then continue to next row...
- At B3, Create column reads No. Therefore, go to next row.
No saving workbook. No need to clear sheets (they are already cleared).
- At B4, if Create column reads Yes then go to C4. If C4 includes numeric value between 1-3 then copy/paste name from column Name_Inc_1 (for this instance, copy/paste Name_13) into cell A1 on worksheet Sheet_Inc_1.
Since B4's numeric value is 2, copy/paste twice. Copy/paste name from column Name_Inc_2 (Name_21) into cell A1 on worksheet Sheet_Inc_2.
Save workbook to desktop as Report_2. Clear sheets then continue to next row...
Reports 1-3 are completed. Macro should finish 90 reports.
Thanks for your help!