Hi all,
I'm reposting this from <here> to the Macro forum as I believe it needs a macro solution.
Bascially, what I need to do is transpose and re-align a messy set of data from the "Data" tab of the attached sheet into the tab "Mailmerge". The format on the Mailmerge tab is how I need it to look to match my mail merge document that this data will feed into.
Underlying reasons for this are: mailmerge requires a certain format and only handles 1 email address in the field, the source data changes frequently and we only want to send one email to each customer.
My macro syntax knowledge is not good, so I was hoping someone might be able to take the "logic" I have written below and turn it into macro code for me?
The logic of the macro needs to do the following:
This macro will get run once per day. It is Ok if it is not the fastest macro, I prefer it to be clear so I can maintain it. Currently the task of sending out 130+ emails takes ~2 HOURS, so a macro + mail merge that takes ~5mins will be a HUGE improvement in our system.
Thanks in advance for all the help.
Regards, Oxi
I'm reposting this from <here> to the Macro forum as I believe it needs a macro solution.
Bascially, what I need to do is transpose and re-align a messy set of data from the "Data" tab of the attached sheet into the tab "Mailmerge". The format on the Mailmerge tab is how I need it to look to match my mail merge document that this data will feed into.
Underlying reasons for this are: mailmerge requires a certain format and only handles 1 email address in the field, the source data changes frequently and we only want to send one email to each customer.
My macro syntax knowledge is not good, so I was hoping someone might be able to take the "logic" I have written below and turn it into macro code for me?
The logic of the macro needs to do the following:
Code:
Sub funky fix up data macro
- clear all existing data on "mailmerge" (except the header row)
- determine the number of columns in data tab
- loop for each column:
- determine if the company name is same as previous column
- if no
- check if "more email flag" is set
- if yes
- loop for each additional email address:
- copy complete last row and paste on next row
- copy next email address into Column D
- check if another email address
- end loop
- clear "more email flag"
- end if
- move to next row and increment ID number (column A)
- copy company name (row1), contact (row2) , email (row6), terms (row4) from Data to Mailmerge2 (columns B - E)
- assign today's date to (Column F)
- copy product (row12), del/pickup (row10), and location (row11) from Data to Mailmerge2 (columns G - I)
- lookup today's price and copy to (column J)
- check if there are further email addresses in rows (7-9):
- if yes, set a variable "more emails flag" with number of extra email address and cell reference
- end if
- next loop
- if yes
- loop for each column of same company name
- copy product (row12), del/pickup (row10), and location (row11) from Data to Mailmerge2 (next 3 columns)
- lookup today's price and copy to (next column)
- end loop
- end loop
- end sub
This macro will get run once per day. It is Ok if it is not the fastest macro, I prefer it to be clear so I can maintain it. Currently the task of sending out 130+ emails takes ~2 HOURS, so a macro + mail merge that takes ~5mins will be a HUGE improvement in our system.
Thanks in advance for all the help.
Regards, Oxi
Attachments
Last edited: