VBA Code to Send Only Today's Entries

Justinian

Well-known Member
Joined
Aug 9, 2009
Messages
1,557
Office Version
  1. 365
Platform
  1. Windows
I have a basic spreadsheet to track when vendor visit our property. It is a running list (as seen below) and I want to install a macro that will e-mail only the contents of the rows with today's date to an assigned recipient.

For example, using the data below, I would like the macro to open an Outlook e-mail and send the contents of rows 3 and 4 since they are the only rows with today's date. I know how to run a macro to e-mail the entire workbook or worksheet but not the individual rows of data. How would I do this?

Outside Contractor - Daily Log.xlsm
ABC
1OC NameDateUnit Code
2Vendor A06/29/2095-96
3Vendor B06/30/20105-45
4Vendor C06/30/20105-97
5
6
Sheet1
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
It says it right here:
send the contents of rows 3 and 4

I still do not see that in that part it says that you want the data in the body of the email.

Either way, in my code in post #11, in the new book, on sheet sh2 you can get the filtered cell range. You can send that range in the body of the email using the code that I put in the link in post #14.
 
Upvote 0
I do not know what you mean. The range will change each day so it will not be static.
 
Upvote 0
I do not know what you mean. The range will change each day so it will not be static.
Every time you execute the code in post #11 it will filter the today's data, that is, it is dynamic. Join my code with the code from post #14 and you will have the filtered data for today's date inserted in the body of the email.
 
Upvote 0
Which section of your code from post #11 and where exactly in the code from post #14 do I put it?
 
Upvote 0
The new code you just wrote attaches the workbook to the e-mail but it does not put the rows with today's date into the e-mail body, which is what I am trying to do.
Before combining the macro, could you tell me if inside that book were only the records with today's dates?
 
Upvote 0
Yes, only after I run the section of code below. The problem is I need code to highlight just today's dates because the Ron Bruin macro you sent me needs the cells to be highlighted in order to be pasted into the body of an e-mail:

Sub Macro1()

' Macro1 Macro
Selection.AutoFilter
ActiveSheet.Range("$A$1:$C$6").AutoFilter Field:=2, Criteria1:=1, Operator _
:=11, Criteria2:=0, SubField:=0
End Sub
 
Upvote 0
The problem is I need code to highlight just today's dates because

Sorry, but I still don't understand, did you want the rows inserted in the body of the email and now you only want them highlighted?
I asked you about post #11 and you give me another code.
I'm sorry but I'm lost with your request, I hope someone else can help because I don't understand what the final goal is.
 
Upvote 0
I want the rows of data that contain today's date in column B to be pasted into the body of an Outlook e-mail.

The macro you sent me in post #14 does this but only if the desired rows are selected first. If nothing is selected, nothing is pasted.

In this example, I want rows 3-5 to be pasted into the body of an e-mail:

Outside Contractors - Daily Log.xlsm
ABC
1OC NameDateUnit Code
2Vendor A07/01/20105-45
3Vendor B07/02/20105-98
4Vendor C07/02/20108-65
5Vendor D07/02/2095-65
Sheet1
 
Upvote 0

Forum statistics

Threads
1,214,978
Messages
6,122,545
Members
449,089
Latest member
davidcom

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