+ Reply to Thread
Results 1 to 14 of 14

VBA custom format adjustment

  1. #1
    Registered User
    Join Date
    01-07-2020
    Location
    england
    MS-Off Ver
    365
    Posts
    79

    VBA custom format adjustment

    Hi,

    The current attached VBA generates an e-mail per each Name from sheet "List" and attaches an xlsx in each e-mail with the associated data for that particular Name.

    Can someone help by adjusting the code so the xlsx file attached in each e-mail will look exactly like "desired result.xlsx" attached in this post?

    (the other functionalities of the VBA should remain the same)
    Attached Files Attached Files
    Last edited by tyxanu; 05-10-2023 at 06:33 AM.

  2. #2
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: VBA custom format adjustment

    Hi there,

    See if the attached version of your workbook does what you need - it uses the following code:

    Please Login or Register  to view this content.
    The highlighted values may be changed to suit your requirements.


    Hope this helps - please let me know how you get on.

    Regards,

    Greg M
    Attached Files Attached Files

  3. #3
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: VBA custom format adjustment

    Hi again,

    The attached version should ensure that colour schemes are copied correctly from the source workbook.

    The highlighted line has been added to the existing routine:

    Please Login or Register  to view this content.

    Hope this helps.

    Regards,

    Greg M
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    01-07-2020
    Location
    england
    MS-Off Ver
    365
    Posts
    79

    Re: VBA custom format adjustment

    Hello Greg,

    This seems fine. I would have one more requirement if you would be able to assist:

    I would like to remove Column R (e-mail address) and have the code perform a vlookup directly by looking for the Names (from Column B) in Sheet "Addresses" and generate the e-mail accordingly (with the relevant data) to the Name's contact stated there.

    Therefor, the code should attach the xlsx containing Sheet "List" in whatever form and format I adjust it (even if I add extra columns/remove columns/change format/etc).

    Huge thanks for this

  5. #5
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: VBA custom format adjustment

    Ok, I'll see what I can do tomorrow

  6. #6
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: VBA custom format adjustment

    Hi again,

    Many thanks for your feedback and also for the Reputation increase - much appreciated!

    The attached workbook is a slightly modified version of the one I posted previously.

    I've added two named cells on the "Addresses" worksheet - the columns which contain these cells may be hidden if required. I've also deleted column "R" from the "List" worksheet.

    The code involved is as follows:

    Please Login or Register  to view this content.

    Hope this helps - as before, please let me know how you get on.

    Regards,

    Greg M
    Last edited by Greg M; 05-12-2023 at 07:40 AM. Reason: Code amended very slightly

  7. #7
    Registered User
    Join Date
    01-07-2020
    Location
    england
    MS-Off Ver
    365
    Posts
    79

    Re: VBA custom format adjustment

    Hi Greg and thanks again ,

    I don't see the attachment in this most recent post. Was it intended to be here?

  8. #8
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: VBA custom format adjustment

    Oops - mea culpa!
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    01-07-2020
    Location
    england
    MS-Off Ver
    365
    Posts
    79

    Re: VBA custom format adjustment

    Hi Greg,

    Sorry, I was away for a couple of days.

    So I have adapted the content and attached my workbook with your code, to be as close as possible to my official data:

    a) column K contains a dropdown for the person to pick some options
    b) based on column K option, column M will get populated accordingly (formula based on hidden Sheet2)

    -----I have filled rows up until 9000 with the above data validation and formula because this is needed to cover as much rows as the user might input------

    Problem: Something is not working right as it seems Excel freezes when I hit "Generate emails". Can you also test based on the attached file?

    Does it have something to do with the 9000 empty cells filled with data validation and formula? (K and M)
    (However, the code should stop and generate/send emails only up until row 7 in our case, based on data from A to I)

    Also, I would need to understand whether the code vlooksup the name from column B, into column A or column D from "Addresses"?

    Appreciate your help!
    Attached Files Attached Files
    Last edited by tyxanu; 05-18-2023 at 06:55 AM.

  10. #10
    Registered User
    Join Date
    01-07-2020
    Location
    england
    MS-Off Ver
    365
    Posts
    79

    Re: VBA custom format adjustment

    Hi Greg

    Have you got the chance to review the above reply?

  11. #11
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: VBA custom format adjustment

    Hi again,

    Hey, nobody said anything about nine thousand rows!

    That sort of number makes a BIG difference to the approach used in producing what is required!

    The original approach deleted unwanted rows on a row-by-row basis - it takes quite some time to individually delete the large number of rows involved!


    The attached version prefixes each instance of the current Addressee Name with an "AAAAA" prefix and then sorts the worksheet to bring the current Addressee to the top of the list. The prefix is then removed.

    When this has been done, the unwanted Addressee rows can be deleted in bulk - this takes far less time than deleting them individually.

    The following code is used:

    Please Login or Register  to view this content.
    The highlighted values can be altered to suit your requirements.


    Hope this helps - as before, please let me know how you get on.

    Regards,

    Greg M
    Attached Files Attached Files

  12. #12
    Registered User
    Join Date
    01-07-2020
    Location
    england
    MS-Off Ver
    365
    Posts
    79

    Re: VBA custom format adjustment

    Hi Greg,

    1. Seems to work fine, except for the part with the addresses.

    If you run the code, for example:

    - to "[email protected]" it attaches John.xlsx and "Dear John..."
    - to "[email protected]" it attaches Richard.xlsx and "Dear Richard..."
    - to "[email protected]" it attaches Ben.xlsx and "Dear Ben..."

    The thing is that in Sheet "Addresses" columns A and B will contain around 2000 addresses, like a contact book. A static list, prone to review once in a while.

    The code should only lookup the Name (column B, Sheet "List") into Sheet "Addresses" column A and generate the e-mail text to the address (column B) matching that name.

    Is this possible? I think it's a much more clean and simple approach, what do you think?

    2. Second point I've wanted to ask you:

    - is the code able to generate/send more than let's say 50 e-mails at once? What about 80?

    Many thanks!
    Attached Files Attached Files
    Last edited by tyxanu; 05-24-2023 at 03:41 AM.

  13. #13
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: VBA custom format adjustment

    Hi again,

    Thanks for the feedback, and sorry, that was my fault!

    To try to speed things up I had disabled automatic calculation, but forgot that the email address of the current UserName must be determined (by calculation) each time. The highlighted additional line in the following routine will do what is required.

    Please Login or Register  to view this content.

    The code can create as many emails as you like, but a possible "bottleneck" is the number of emails which your email service provider will accept. In a different application (using Gmail via Outlook) I've restricted the size of a "batch" of emails to 80, and have not encountered problems to date.

    It should be a relatively straightforward job for you to send your emails in appropriately-sized batches.


    Regards,

    Greg M



    P.S.


    The thing is that in Sheet "Addresses" columns A and B will contain around 2000 addresses, like a contact book. A static list, prone to review once in a while.

    The code should only lookup the Name (column B, Sheet "List") into Sheet "Addresses" column A and generate the e-mail text to the address (column B) matching that name.

    Is this possible? I think it's a much more clean and simple approach, what do you think?

    This is the approach used in the current and previous workbooks.
    Attached Files Attached Files
    Last edited by Greg M; 05-24-2023 at 12:55 PM. Reason: P.S. added

  14. #14
    Registered User
    Join Date
    01-07-2020
    Location
    england
    MS-Off Ver
    365
    Posts
    79

    Re: VBA custom format adjustment

    Greg, you're a god!

    Let me play around with it and test all the scenarios and I'll get back to you.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. How to change Pivot Chart axis number format to a custom date format
    By paulma1960 in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 01-11-2023, 03:16 PM
  2. Format Cells -> Custom Number with Custom Color
    By Cardan in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 02-22-2021, 08:19 AM
  3. Replies: 5
    Last Post: 01-25-2020, 05:18 PM
  4. [SOLVED] Date Format Adjustment?
    By watson150 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-15-2020, 06:15 PM
  5. [SOLVED] split formula format litrage measurement need adjustment not giving expected results
    By JEAN1972 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-17-2018, 12:49 PM
  6. Custom format to text same as custom format
    By selim69 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 01-21-2018, 08:12 AM
  7. select adjustment tab in cell format dialog
    By x taol in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-22-2006, 12:35 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1