View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
[email protected] fredrik.kjell@gmail.com is offline
external usenet poster
 
Posts: 3
Default 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