mardi 23 juillet 2019

VBA macro copy/paste names to specific sheets if conditions are met. loop to next row, repeat

I have a VBA question on how to create a macro that will copy/paste names to specific worksheets if conditions are met. A few examples below...

  • B12 is Yes. Include is 1. Exclude is 0. Therefore, copy/paste NameG1 to cell A1 of Name_Inc_1. Save workbook to desktop as Report1 (column D). Clear A1 from all tabs (besides Setup tab) then move to next row.

  • B13 is Yes. Include is 2; Exclude is 1. Therefore, copy/paste NameG2 to cell A1 of Name_Inc_1. Also, copy/paste NameH1 to cell A1 of Name_Inc_2 (because include tab is 2). Copy/paste NameM1 to cell A1 of Name_Exc_1. Save workbook to desktop as Report2 (column D). Clear A1 from all tabs (besides Setup tab) then move to next row.

  • B14 is No. Move to next row. No need to save workbook or clear tab (already cleared).

The code I attempted is messy and not helpful (I have just started learning VBA). Googling things isn't helping me too much right now. I know I would use code such as IF, ELSE, THEN, LOOP but I am just getting confused.

image of excel using snipping tool

Your help is very much appreciated!.

Thanks!

Aucun commentaire:

Enregistrer un commentaire