+ Reply to Thread
Results 1 to 14 of 14

Need VBA code to popup Email Depends upon userform of Segment

  1. #1
    Forum Contributor
    Join Date
    04-30-2013
    Location
    washington
    MS-Off Ver
    Excel 2019
    Posts
    168

    Need VBA code to popup Email Depends upon userform of Segment

    Dear expert

    I have brokers collection data , i want send mail from userform1,2,3,4 , each userform will assisgned for each company name.

    like A column have company name Patriot Lithium Ltd i have userform1 for this company, if i click button Email Report,

    its popup with dashboard only corresponding data values from Today_Report Table.

    so The email report get change dashboard dynamically depends upon company name.

    assume Patriot Lithium Ltd i draft email for this company which i want in automation


    Please find the attachment
    image file is my expected result when click Email Report button from userform
    Attached Images Attached Images
    Attached Files Attached Files

  2. #2
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Need VBA code to popup Email Depends upon userform of Segment

    Do you want to select companies one by one or do you want to run the report for the companies all at once?
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

  3. #3
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Need VBA code to popup Email Depends upon userform of Segment

    Here is a version that lets you mail the reports one at a time. I notice that tables 3 and 4 are "fixed."

    I added a Mail Setup sheet to do lookups and some computations.

    The table in columns A:C are used to select the companies and to get the email addresses for the TO and CC parts of the email. As you add or delete information, the lookups will change to show what is current.

    The mail flag can be either true or false. If it is false, the mail is prepared and put on the screen, but not sent. This gives to an opportunity to edit it. If the flag is true, it goes out automatically.

    I also have a Mail Body sheet which collects and formats the data for the selected company.

    The Raw Data Records is a check calculation. The pivot table filters can't be set if there is no data for the company, so I make a check for that and give you a warning.

    I also do a check to see if there is no address for the TO block in the email.

    Select the company for which you want a report and click on the mail report button.

    I have Excel 365 which has XLOOKUP. If 2019 doesn't have this command, you can use VLOOKUP.

    You can use the MailMain and RangeToHTML modules as "plug and play" for future projects. All you have to do is pass the parameters.
    Attached Files Attached Files

  4. #4
    Forum Contributor
    Join Date
    04-30-2013
    Location
    washington
    MS-Off Ver
    Excel 2019
    Posts
    168

    Re: Need VBA code to popup Email Depends upon userform of Segment

    i want make send for all companies in one shot in cmd button ?Popup with email body of each company. then i click send to fly.
    i want run code from new sheet as index, dashboard sheet should be hide becoz logic is other team have no clue of others data
    Last edited by johnlara; 12-12-2022 at 07:25 AM. Reason: file missing

  5. #5
    Forum Contributor
    Join Date
    04-30-2013
    Location
    washington
    MS-Off Ver
    Excel 2019
    Posts
    168

    Re: Need VBA code to popup Email Depends upon userform of Segment

    Thanks bro enough for me it works, just small change i want hide the dashboard sheet, send email from index page ,create one index sheet set up filter and cmd button fine for me

  6. #6
    Forum Contributor
    Join Date
    04-30-2013
    Location
    washington
    MS-Off Ver
    Excel 2019
    Posts
    168

    Re: Need VBA code to popup Email Depends upon userform of Segment

    HI sir

    please find the attachment sheet index create email from the combobx list
    Attached Files Attached Files

  7. #7
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Need VBA code to popup Email Depends upon userform of Segment

    I am a little bit confused by the requirement.

    You can hide whatever you want, but it still needs to be there to run "behind the scenes."

    The user form seems to be set up for one company at a time. I see where the combobox is, but I don't know what the other three fields in the form are for.

    Here is a version that launches the form. At the moment I have the code "stubbed out." You can select all which means that mail will be sent to all companies, or you can select a specific company which means that mail is sent ONLY to that company. The form stays open until you click the exit button. Let me know if you want to pursue this design.
    Attached Files Attached Files

  8. #8
    Forum Contributor
    Join Date
    04-30-2013
    Location
    washington
    MS-Off Ver
    Excel 2019
    Posts
    168

    Re: Need VBA code to popup Email Depends upon userform of Segment

    Yes sir initially i had plan to keep multiple userform for each company, but its long process to design and validate each one of them so i want keep all in one now, thanks for code, its works solved

  9. #9
    Forum Contributor
    Join Date
    04-30-2013
    Location
    washington
    MS-Off Ver
    Excel 2019
    Posts
    168

    Re: Need VBA code to popup Email Depends upon userform of Segment

    Hi sir can u check form u added nothing happen for me , i click button its just popup up msg box.

  10. #10
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Need VBA code to popup Email Depends upon userform of Segment

    I assume that you are ok with the overall design, so here it is "hooked up" to the mailer.

    I hid all the sheets except for the index sheet. You will still have to configure the companies in the mail setup sheet. You can delete the Expected_Result sheet
    Attached Files Attached Files

  11. #11
    Forum Contributor
    Join Date
    04-30-2013
    Location
    washington
    MS-Off Ver
    Excel 2019
    Posts
    168

    Re: Need VBA code to popup Email Depends upon userform of Segment

    HI sir, i getting error,
    Attached Images Attached Images

  12. #12
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Need VBA code to popup Email Depends upon userform of Segment

    The error message doesn't make sense. It's saying that what is in cell G2 on the Mail Setup sheet (Named Mail_To) is something other than a string. What kind of data do you have in the To column on the Mail Setup sheet? Also, does it fail on the first record or if some other record, what line does it fail on and what does that data look like?

  13. #13
    Forum Contributor
    Join Date
    04-30-2013
    Location
    washington
    MS-Off Ver
    Excel 2019
    Posts
    168

    Re: Need VBA code to popup Email Depends upon userform of Segment

    sorry for delay reply expert, thanks for your timely help i forgot my password i couldnt login

  14. #14
    Forum Contributor
    Join Date
    04-30-2013
    Location
    washington
    MS-Off Ver
    Excel 2019
    Posts
    168

    Re: Need VBA code to popup Email Depends upon userform of Segment

    Amazing skill Thread is solved

+ 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. Replies: 7
    Last Post: 07-08-2019, 01:23 PM
  2. [SOLVED] Sort the values depends upon first three segment
    By johnmacpro in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 08-01-2016, 03:24 AM
  3. [SOLVED] Need vba code to get row lines from master through A and C col key code segment wise
    By johnlara in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-12-2016, 12:29 AM
  4. I need to add a verify segment to this code
    By superchew in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-17-2016, 09:53 AM
  5. need vba code to split rows to closed wb shets depends company code met with sht name
    By julielara in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-18-2016, 12:44 PM
  6. Ms access Vba Save Data to xl depends upon 1 table pick & Depends 2 Upon fiterDate
    By breadwinner in forum Access Programming / VBA / Macros
    Replies: 14
    Last Post: 05-29-2014, 10:59 PM
  7. Macro to segment list and email
    By gtiguy in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-19-2012, 03:25 AM

Tags for this Thread

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