Hi, I have a spreadsheet that contains mailing list data. It's in a format in which there are Alt1Email (column R), Alt2Email (column S), Alt3Email (column T), and Alt4Email (column U). Wanna cut and paste that data from those columns to the Email column (column Q) in NEW ROWs based on how many AltEmails the contact has. Then ultimately delete columns R,S,T, and U. I thought this out in a plain logic script (below) but being new to VBA I'm having trouble understand syntax a bit. Please if anyone can assist would greatly appreciate. Kind regards! Attached is the spreadsheet and screenshots.. Thanks!
----------
{If cells in columns R,S,T,U are all Populated (not null) in the row the VBA script is working on... first row being row TWO... so R2,S2,T2,U2)
then
INSERT FOUR new rows BELOW this row
AND
COPY from that "reference" row the cell values from columns A thru P... to the corresponding columns of the 4 new rows just created,
AND
CUT cell value from column R AND PASTE IT to the FIRST new row immediately under the original "reference" row into COLUMN Q
AND
CUT column S value and paste to SECOND new row's Q column
AND
CUT column T value and paste to THIRD new row's Q column
AND
CUT column U value and paste to FOURTH new row's Q column}
OR
{If out of R,S,T,U.... only columns R,S, & T (only 3 alt-emails) are populated in the current "reference" row
then
INSERT THREE new rows below this row
AND
COPY from that "reference" row the cell values from columns A thru P... and paste into to the corresponding columns of the THREE new rows just created,
AND
CUT cell value from column R AND PASTE IT to the FIRST new row immediedly under the original "reference" row
INTO COLUMN Q
AND
CUT column S value and paste to SECOND new row's Q column
AND
CUT column T value and paste to THIRD new row's Q column}
OR
{If out of R,S,T,U, only R & S (only 2 alt-emails) are populated in that "reference" row
then
INSERT TWO new rows below the reference row
AND
copy from that "reference" row the cell values from columns A thru P... and PASTE to the corresponding columns of the THREE new rows just created,
AND
CUT cell value from column R AND PASTE IT to the FIRST new row immediedly under the original "reference" row to COLUMN Q
AND
CUT column S value and Paste to SECOND new row's Q column}
OR
{If out of R,S,T, U, only column R is populated in that particular row)
then
INSERT ONE new row below the reference row
AND COPY from that "reference" row the cell values from columns A thru P... and paste into to the corresponding columns of the THREE new rows just created,
AND
CUT cell value from column R AND PASTE IT to the FIRST new row immediedly under the original "reference" row into COLUMN Q}
{If we just added 4 new rows, move down FIVE rows from the original row... if this new “reference” row is a totally blank row, END this script,
If not, make THIS row the new “reference” row AND go back to beginning of script
if we just added 3 new rows, move down FOUR rows from the original row... if this is a totally blank row, END this script
If not, make THIS row the new “reference” row AND go back to beginning of script
{if we just added 2 new rows, move down THREE rows from the original row... if this is a totally blank row, END this script,
If not, make THIS row the new “reference” row AND go back to beginning of script}
{if we just added 1 new row, move down 2 rows from the original row... if this is a totally black row, END this script, if not, make THIS row the new criteria row}
{if we added no new rows in the above process, move down to the next row below original row. if this is a totally BLANK NULL row, END this script,}
Go back to beginning criteria of this script
-------
Example:
Sheet example BEFORE running VBA script:
Sheet example AFTER running VBA script:
----------
{If cells in columns R,S,T,U are all Populated (not null) in the row the VBA script is working on... first row being row TWO... so R2,S2,T2,U2)
then
INSERT FOUR new rows BELOW this row
AND
COPY from that "reference" row the cell values from columns A thru P... to the corresponding columns of the 4 new rows just created,
AND
CUT cell value from column R AND PASTE IT to the FIRST new row immediately under the original "reference" row into COLUMN Q
AND
CUT column S value and paste to SECOND new row's Q column
AND
CUT column T value and paste to THIRD new row's Q column
AND
CUT column U value and paste to FOURTH new row's Q column}
OR
{If out of R,S,T,U.... only columns R,S, & T (only 3 alt-emails) are populated in the current "reference" row
then
INSERT THREE new rows below this row
AND
COPY from that "reference" row the cell values from columns A thru P... and paste into to the corresponding columns of the THREE new rows just created,
AND
CUT cell value from column R AND PASTE IT to the FIRST new row immediedly under the original "reference" row
INTO COLUMN Q
AND
CUT column S value and paste to SECOND new row's Q column
AND
CUT column T value and paste to THIRD new row's Q column}
OR
{If out of R,S,T,U, only R & S (only 2 alt-emails) are populated in that "reference" row
then
INSERT TWO new rows below the reference row
AND
copy from that "reference" row the cell values from columns A thru P... and PASTE to the corresponding columns of the THREE new rows just created,
AND
CUT cell value from column R AND PASTE IT to the FIRST new row immediedly under the original "reference" row to COLUMN Q
AND
CUT column S value and Paste to SECOND new row's Q column}
OR
{If out of R,S,T, U, only column R is populated in that particular row)
then
INSERT ONE new row below the reference row
AND COPY from that "reference" row the cell values from columns A thru P... and paste into to the corresponding columns of the THREE new rows just created,
AND
CUT cell value from column R AND PASTE IT to the FIRST new row immediedly under the original "reference" row into COLUMN Q}
{If we just added 4 new rows, move down FIVE rows from the original row... if this new “reference” row is a totally blank row, END this script,
If not, make THIS row the new “reference” row AND go back to beginning of script
if we just added 3 new rows, move down FOUR rows from the original row... if this is a totally blank row, END this script
If not, make THIS row the new “reference” row AND go back to beginning of script
{if we just added 2 new rows, move down THREE rows from the original row... if this is a totally blank row, END this script,
If not, make THIS row the new “reference” row AND go back to beginning of script}
{if we just added 1 new row, move down 2 rows from the original row... if this is a totally black row, END this script, if not, make THIS row the new criteria row}
{if we added no new rows in the above process, move down to the next row below original row. if this is a totally BLANK NULL row, END this script,}
Go back to beginning criteria of this script
-------
Example:
Sheet example BEFORE running VBA script:
Add-Specific-Number-of-Rows-And-Populate-Based-On-Cell-Value.xlsx | |||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | |||
1 | Category A | Category B | Category C | Category D | Category E | Category F | Category G | Category H | Category I | Category J | FirstName | LastName | Personal | Close Personal | What | Company | AltEmail1 | AltEmail2 | AltEmail3 | AltEmail4 | |||
2 | x | x | x | x | x | x | Albert | Hammond | x | x | Guitarist | Roland | ahammond@gmail.com | fenderbender@gmail.com | |||||||||
3 | x | x | x | x | Cynthia | Jones | Painter | Warhol Inc. | info@warhol.com | cynthia@warhol.inc | cjones@gmail.com | ||||||||||||
4 | x | Derrick | Lewis | Carpenter | All Done Right Inc. | derrick_lewis@alldoneright.org | |||||||||||||||||
5 | x | Edward | Alby | x | Lighting Designer | Brighter Days | albyed@brigherdays.com | e.alby@gmail.com | e.alby@mac.com | ||||||||||||||
6 | x | x | x | x | Jeff | Cousins | x | x | Dancer | Breakin Up Inc. | jeffcousins@gmail.com | ||||||||||||
7 | x | x | Marcus | Kaufman | x | Singer | Lauren Nicole | marcusk@ln.com | |||||||||||||||
8 | x | Lauren | Betts | Drummer | First Instruments | laurenbetts@hotmail.com | |||||||||||||||||
9 | x | x | x | x | Pauline | Huerta | x | Acrobat | Mission Inc. | aria101@aol.com | |||||||||||||
10 | x | x | x | x | x | x | x | Richard | Grove | x | Broadcaster | ABC | c.martini@missoni.it | richard.grove@abc.com | rgrove@gmail.com | grove131@hotmail.com | rgrove@grove.com | ||||||
Before |
Sheet example AFTER running VBA script:
Add-Specific-Number-of-Rows-And-Populate-Based-On-Cell-Value.xlsx | |||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | |||
1 | Category A | Category B | Category C | Category D | Category E | Category F | Category G | Category H | Category I | Category J | FirstName | LastName | Personal | Close Personal | What | Company | AltEmail1 | AltEmail2 | AltEmail3 | AltEmail4 | |||
2 | x | x | x | x | x | x | Albert | Hammond | x | x | Guitarist | Roland | ahammond@gmail.com | ||||||||||
3 | x | x | x | x | x | x | Albert | Hammond | x | x | Guitarist | Roland | fenderbender@gmail.com | ||||||||||
4 | x | x | x | x | Cynthia | Jones | Painter | Warhol Inc. | info@warhol.com | ||||||||||||||
5 | x | x | x | x | Cynthia | Jones | Painter | Warhol Inc. | cynthia@warhol.inc | ||||||||||||||
6 | x | x | x | x | Cynthia | Jones | Painter | Warhol Inc. | cjones@gmail.com | ||||||||||||||
7 | x | Derrick | Lewis | Carpenter | All Done Right Inc. | derrick_lewis@alldoneright.org | |||||||||||||||||
8 | x | Edward | Alby | x | Lighting Designer | Brighter Days | albyed@brigherdays.com | ||||||||||||||||
9 | x | Edward | Alby | x | Lighting Designer | Brighter Days | e.alby@gmail.com | ||||||||||||||||
10 | x | Edward | Alby | x | Lighting Designer | Brighter Days | e.alby@mac.com | ||||||||||||||||
11 | x | x | x | x | Jeff | Cousins | x | x | Dancer | Breakin Up Inc. | jeffcousins@gmail.com | ||||||||||||
12 | x | x | Marcus | Kaufman | x | Singer | Lauren Nicole | marcusk@ln.com | |||||||||||||||
13 | x | Lauren | Betts | Drummer | First Instruments | laurenbetts@hotmail.com | |||||||||||||||||
14 | x | x | x | x | Pauline | Huerta | x | Acrobat | Mission Inc. | aria101@aol.com | |||||||||||||
15 | x | x | x | x | x | x | x | Richard | Grove | x | Broadcaster | ABC | c.martini@missoni.it | ||||||||||
16 | x | x | x | x | x | x | x | Richard | Grove | x | Broadcaster | ABC | richard.grove@abc.com | ||||||||||
17 | x | x | x | x | x | x | x | Richard | Grove | x | Broadcaster | ABC | rgrove@gmail.com | ||||||||||
18 | x | x | x | x | x | x | x | Richard | Grove | x | Broadcaster | ABC | grove131@hotmail.com | ||||||||||
19 | x | x | x | x | x | x | x | Richard | Grove | x | Broadcaster | ABC | rgrove@grove.com | ||||||||||
After |