+ Reply to Thread
Results 1 to 12 of 12

Email VBA script help

  1. #1
    Registered User
    Join Date
    03-30-2012
    Location
    wakefield
    MS-Off Ver
    Excel 2003
    Posts
    23

    Email VBA script help

    Hi,

    I've tried adopting the script below to suit my needs, but it doesn't work. Basically I need to look up a name in column B, if it matches it will send the entire row (or number of rows if more than 1 match) to the email address in the worksheet "MailinfoA".

    I have adapted this from a script which looks up column A, but I'm already using this script and need to run another looking at column B if this makes sense.
    Please Login or Register  to view this content.
    Can anyone help here, the script worked before I tried to amend.

    Moderator's note: Please take the time to review our rules. There aren't many, and they are all important. Rule #3 requires code tags. I have added them for you this time but you are not a new member so should know this rule. --6StringJazzer

    Thanks
    Last edited by 6StringJazzer; 01-18-2018 at 11:53 AM.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,705

    Re: Email VBA script help

    Please explain what "doesn't work" means.
    • Does the code run?
    • Does it run but do nothing?
    • Does it produce error messages? If so, what do the messages say?
    • Does it produce unexpected/wrong results? If so, how do the results differ from what you expect?
    • Does it hang?
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    03-30-2012
    Location
    wakefield
    MS-Off Ver
    Excel 2003
    Posts
    23

    Re: Email VBA script help

    Hi,

    Apologies for not adding the code tag.

    Yes it runs but doesn't do anything, so it doesn't bring up any errors.

  4. #4
    Registered User
    Join Date
    03-30-2012
    Location
    wakefield
    MS-Off Ver
    Excel 2003
    Posts
    23

    Re: Email VBA script help

    Hi, anyone have any ideas?

  5. #5
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,705

    Re: Email VBA script help

    There are several conditions that could cause this code to do nothing. The quickest way to debug this is to see your data. Can you provide your Excel file with data? You can alter the email addresses and other private information, but the problem could be in your data just as easily as it could be in the code.

  6. #6
    Registered User
    Join Date
    03-30-2012
    Location
    wakefield
    MS-Off Ver
    Excel 2003
    Posts
    23

    Re: Email VBA script help

    deleted post
    Last edited by uksoundz; 01-31-2018 at 10:09 AM.

  7. #7
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,705

    Re: Email VBA script help

    Sorry, I do not trust that web site. Please attach your file directly in a post here.

    The paper clip icon does not work for attachments. Instead, under the text box where you type your reply click the Go Advanced button. On the next screen scroll down and click on Manage Attachments, which will show a pop-up window to Select and Upload a file. Then close the window.

  8. #8
    Registered User
    Join Date
    03-30-2012
    Location
    wakefield
    MS-Off Ver
    Excel 2003
    Posts
    23

    Re: Email VBA script help

    Hi,

    I have attached the file below, basically the 'Email Managers' link works fine, but the 'Email Regional Managers' doesn't do anything and I'm not sure why.

    I want the Email Regional Managers macro to lookup the regional manager column in the populated tab and email those to the regional managers.

    The ideally I would like to combine both these as one macro where firstly it looks up the Manager column and emails just those to the Managers, then looks up the Regional Managers column and emails just those to the Regional Managers.

    Hope I've made sense, and thanks for your help!
    Attached Files Attached Files
    Last edited by uksoundz; 01-31-2018 at 10:09 AM.

  9. #9
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,705

    Re: Email VBA script help

    OK, got it. There are two subs in your file regional and manager. Which is the one you are trying to get to work?

    Basically I need to look up a name in column B, if it matches it will send the entire row (or number of rows if more than 1 match) to the email address in the worksheet "MailinfoA".
    What are you looking up in column B to match? This code appears to send email to all values in column B, not just the ones that match something else.

  10. #10
    Registered User
    Join Date
    03-30-2012
    Location
    wakefield
    MS-Off Ver
    Excel 2003
    Posts
    23

    Re: Email VBA script help

    The regional one doesn't work.

    The manager sub works fine, that looks up the name in column A of the populated sheet and matches it to the email address in the MailInfo sheet, this then creates a workbook with just the rows that have that specific managers name in column A and emails it to them.

    The regional one doesn't work, I want that to look up the names in column B of the populated sheet and match it to the email address in the MailInfoA sheet, and create a workbook with just the rows that have that specific regional managers name in column B and email it to them.

  11. #11
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,705

    Re: Email VBA script help

    Quote Originally Posted by uksoundz View Post
    [...]create a workbook with just the rows that have that specific regional managers name in column B and email it to them.
    Do you really need a new workbook? What if the emails can be sent without creating a new workbook just to list them? I think the existing code is far more complex than what is required, by the way.

  12. #12
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,705

    Re: Email VBA script help

    I think I see why your code is creating new workbooks; it filters down to each manager's information and then makes it an attachment.

    Here is the reason your code is not doing anything.

    Please Login or Register  to view this content.
    The name of your worksheet is not MailinfoA, it is MaiIinfoA.

    To make matters worse, you have this:

    Please Login or Register  to view this content.
    This is a poor coding practice because it hides errors. The reference to a non-existing worksheet is causing a subscript reference error, but you never see it because when it occurs your code just goes to cleanup.

+ 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. VBA Script to Email Sheet and Other Attachment
    By jharvey87 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-24-2015, 03:54 PM
  2. Amend Email VBA Script
    By Vinny1959 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-31-2015, 08:48 AM
  3. Run Script for most recent email only
    By mikey3580 in forum Outlook Programming / VBA / Macros
    Replies: 1
    Last Post: 11-10-2014, 05:49 PM
  4. Help with an email script
    By starlev in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-01-2014, 04:28 AM
  5. Send New Email Script in VB
    By edneal2 in forum Outlook Formatting & Functions
    Replies: 1
    Last Post: 07-01-2013, 12:43 AM
  6. Script or Macro to send an email
    By pradeepkodali in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 09-01-2011, 07:55 PM
  7. email vba script
    By jpruffle in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-27-2009, 10:44 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