ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro to place dated rows in email and send??? (https://www.excelbanter.com/excel-programming/374860-macro-place-dated-rows-email-send.html)

PG Oriel

Macro to place dated rows in email and send???
 
Hi, I have a worksheet that has rows that are dated.

What I'm looking for is a macro that copies the current day's rows (there
can be more than one row with the current date) and then put it in an email
and send it.

I have tried recording a macro to do it but have had no success.

Any help is great.

Thanks.

[email protected]

Macro to place dated rows in email and send???
 
The following method will check for valid rows. In my example, the data
is organized as this:

[date] [value] <-- column A holds the dates, column B holds the data

Example:

2006-10-11 (column A)
values (column B)

The method will NOT email the results. Just hit Google with "Excel vba
send mail" and you will have plenty of examples. Your problem with
finding the correct cells can be solved in numerous ways, here it one
I've succesfully tested.


Sub FetchTodaysRows()

Dim ws As Worksheet
Dim rngData As Range
Dim c As Range
Dim strOut As String

'worksheet containing data
Set ws = Worksheets("mydata")

'the range where the data is
Set rngData = ws.Range("A1:A10")

For Each c In rngData

If c.Value = Date Then
strOut = strOut & c.Value & " " & c.Offset(0, 1).Value &
Chr(10)
End If

Next c

Debug.Print strOut

End Sub

Please note:

..Offset(0,1).Value <-- gives the value of column b
Chr(10) <-- add a line feed

-Fredrik



All times are GMT +1. The time now is 12:44 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com