+ Reply to Thread
Results 1 to 11 of 11

[VBA] [Generate Email] - End of Subject line

  1. #1
    Registered User
    Join Date
    11-09-2012
    Location
    seattle
    MS-Off Ver
    Excel 2007
    Posts
    42

    [VBA] [Generate Email] - End of Subject line

    Hello,

    I have a VBA Macro set to generate an Outlook email based on data in my userform. I already have conditions and IF statements written out to generate the subject line contents. However, I am hoping to find a way to have the macro check if ComboBox1 = "Y", then add "Hello" to the end of the Subject line already existing contents. Any help would be great

  2. #2
    Registered User
    Join Date
    01-22-2017
    Location
    Michigan
    MS-Off Ver
    365
    Posts
    61

    Re: [VBA] [Generate Email] - End of Subject line

    What code are you already using to input the subject line?

  3. #3
    Registered User
    Join Date
    11-09-2012
    Location
    seattle
    MS-Off Ver
    Excel 2007
    Posts
    42

    Re: [VBA] [Generate Email] - End of Subject line

    I am using the below code:
    Its really confusing, but basically I already have an IF statement that has to run in the macro. Once this IF statement is complete it adds the data I need to the Subject line. After that I need to add three different checks/conditions based on other ComboBoxes. Those three checks will add additional text to the end of the contexts I already have in the subject line. I hope that makes sense.

    With OutMail

    .To = TextBox19.Text & ";" & TextBox18.Text & ";" & TextBox15.Text & ";" & TextBox16.Text
    .CC = TextBox24.Text & ";" & TextBox25.Text
    .BCC = ""

    'IF CONDITION STATEMENT...................

    If TextBox41 = "" Then

    .Subject = TextBox10.Text & "/" & TextBox1.Text

    GoTo CT
    Else
    End If

    .Subject = TextBox10.Text & "/" & TextBox1.Text & " & " & TextBox41

    CT:
    .HTMLBody = RangetoHTML(Rng)
    .Display

    End With

  4. #4
    Registered User
    Join Date
    01-22-2017
    Location
    Michigan
    MS-Off Ver
    365
    Posts
    61

    Re: [VBA] [Generate Email] - End of Subject line

    try this after your last End if:

    Please Login or Register  to view this content.
    This replaces:
    .Subject = TextBox10.Text & "/" & TextBox1.Text & " & " & TextBox41

  5. #5
    Registered User
    Join Date
    01-22-2017
    Location
    Michigan
    MS-Off Ver
    365
    Posts
    61

    Re: [VBA] [Generate Email] - End of Subject line

    oh I missed that goto command.

    Your first IF statement will have to be this:

    Please Login or Register  to view this content.
    You are allowed to nest IF statements
    Last edited by Soulfien; 05-24-2017 at 05:12 PM.

  6. #6
    Registered User
    Join Date
    11-09-2012
    Location
    seattle
    MS-Off Ver
    Excel 2007
    Posts
    42

    Re: [VBA] [Generate Email] - End of Subject line

    Not sure if that is going to work cause I have three checks to make, listing below. All three come after the primary IF statement I have above.

    If ComboBox1 = "Y" & ComboBox2 = "Y" Then "Hello World"
    Else

    If ComboBox1 = "Y" Then "Hello"
    Else

    If ComboBox2 = "Y" Then "World"

  7. #7
    Registered User
    Join Date
    01-22-2017
    Location
    Michigan
    MS-Off Ver
    365
    Posts
    61

    Re: [VBA] [Generate Email] - End of Subject line

    .....................................
    Last edited by Soulfien; 05-24-2017 at 06:35 PM.

  8. #8
    Registered User
    Join Date
    01-22-2017
    Location
    Michigan
    MS-Off Ver
    365
    Posts
    61

    Re: [VBA] [Generate Email] - End of Subject line

    So the whole thing will be:
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    11-09-2012
    Location
    seattle
    MS-Off Ver
    Excel 2007
    Posts
    42

    Re: [VBA] [Generate Email] - End of Subject line

    Awesome, this is what I needed. Testing now!
    Question though, I shouldn't need the CT: since its not part of the IF statement, correct?

  10. #10
    Registered User
    Join Date
    01-22-2017
    Location
    Michigan
    MS-Off Ver
    365
    Posts
    61

    Re: [VBA] [Generate Email] - End of Subject line

    Correct. That can go away.

  11. #11
    Registered User
    Join Date
    11-09-2012
    Location
    seattle
    MS-Off Ver
    Excel 2007
    Posts
    42

    Re: [VBA] [Generate Email] - End of Subject line

    Thank you so much, worked perfectly! :D

+ 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. [SOLVED] Verify Email Subject Line
    By dineshsachidananda in forum Outlook Formatting & Functions
    Replies: 1
    Last Post: 04-26-2016, 03:05 PM
  2. Hyperlinks - email - subject line - etc
    By Youtalk in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-17-2012, 03:41 PM
  3. Add cell value to email subject line
    By shariq1989 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 06-02-2012, 01:28 PM
  4. Tab Name in Email Subject Line
    By dagindi in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-20-2010, 02:37 PM
  5. Value of a cell for email subject line
    By Kevin K. Chlipa in forum Excel General
    Replies: 4
    Last Post: 11-28-2008, 06:45 PM
  6. Email subject line in VBA using Sendmail
    By arnoldn5 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-04-2007, 08:00 PM
  7. Changing subject line in email
    By tanyhart in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-07-2006, 11:34 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