taykaisheng
New Member
- Joined
- Jul 30, 2013
- Messages
- 10
Hi, I am on an assignment to count the number of rows which contain specific text and print the value on email. However I'm stuck here
Here are my code
My current code will return all the value as "0" eventhough "Orange" does exist in one of the row. Hope someone could help me to solve the problem. Thank You
Here are my code
Code:
Public Function First()Dim Source As Workbook
Dim Var1 As Integer
Dim Var10 As Integer
Dim Source2 As Workbook
Set Source = Workbooks.Open("C:\Users\HP\Desktop\IN INPROG.xlsx")
Var1 = Application.WorksheetFunction.CountIf(Range("M1:M100"), "Orange")
Source.Close SaveChanges:=False
Set Source2 = Workbooks.Open("C:\Users\HP\Desktop\SR INPROG.xlsx")
Var10 = Application.WorksheetFunction.CountIf(Range("M1:M100"), "Orange")
Source2.Close SaveChanges:=False
eTo = "orange@aod.au"
esubject = Format(Date, "d/mmmm/yyyy") & " " & "Weekly Open Incident Reminder"
ebody = "Dear All," & vbCrLf & "" & vbCrLf & "" & vbCrLf & "Orange: " & "SR: " & Var10 & " IN: " & Var1
Set app = CreateObject("Outlook.Application")
Set itm = app.createitem(0)
On Error Resume Next
With itm
.Subject = esubject
.To = eTo
.body = ebody
.display
My current code will return all the value as "0" eventhough "Orange" does exist in one of the row. Hope someone could help me to solve the problem. Thank You