send email as boolean or ina user form check box

rjmdc

Well-known Member
Joined
Apr 29, 2020
Messages
742
Office Version
  1. 365
Platform
  1. Windows
hi
I recently got help and added code to send a specific email if the date i run the process is before the 23rd.
now i bumped into a bug. i can run this prcess 2 x in a day once for current infor and once for past info and I dont want the emails to be sent 2x.
I am using a user form to input all parameters such as dte and run etc i can add a send emails check box but i dont know how to code it in the form and how to add that in my code
please help me

Rich (BB code):
VBA Code:
    <span>If</span> Day<span>(</span><span>Date</span><span>)</span> <span>&lt;</span><span>=</span> <span>23</span> <span>Then</span><br>        <span>Call</span> SendExpirationEmails<span>(</span><span>False</span><span>)</span><br>    <span>End</span> <span>If</span>
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Your code got messed up there but I'll let you fix it and make it readable. You probably need a helper cell somewhere. If there are many rows in a sheet that provide data for the email (one row per email) then the helper cell would be in an additional column, which I think can be hidden if you want. When you send email based on a row, you'd put a value in the helper cell. When you go to run this operation, an additional check would be whether or not there is a value in the helper cell. I'd use a date/time value as it would also tell you when the email was sent.

Without seeing what you base the userform and/or email on, it's really not possible to be very specific.
 
Upvote 0
OK, I used ctrl+h to remove the html. What that says is
If Day(Date) >= 23 Then
If you use my suggestion and the helper cell is H2 then do another check for a value there. One way:
If Day(Date) >= 23 And Range("H2")<>"" Then

Using a date would also allow you to make more comparisons. You might want to resend tomorrow but not today. Or you might not use dates at all since you seem to have 2 situations for sending, so maybe you put a value that denotes whether it was sent as current or past info. Again, I'm just rambling with ideas but without any notion of what the data looks like, or even if there is any sheet data involved at all.
 
Upvote 0

Forum statistics

Threads
1,225,739
Messages
6,186,738
Members
453,369
Latest member
juliewar

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top