Hey everybody,
My name's Joel, and I work at a leading distance education school. I'm working on a pipeline tool to help take some of the manual paper lead management out of some of our representatives work.
I'm testing an application that loops through dates until it finds all similar values by discriminating against the next unique item in a sorted column. Then the lead should plug related info into outlook. Individually, each piece I've tried ultimately works. It's just putting it all together that's the bear.
The Run-time error ' 13 mismatch error appears to be arising out of the counter variable that I'm trying to load into the body of an outlook appointment.
Any tips, questions, suggestions, corrections would be appreciated.
Sub Test()
Set cp3sheet = ThisWorkbook.Sheets("CP3 Tracking Log")
Set BG = ThisWorkbook.Sheets("Backgrounds")
'Set overall boundaries.
SC = Selection.Column
FR = cp3sheet.Cells(3, SC).Row
LR = cp3sheet.Cells(Rows.Count, SC).End(xlUp).Row
SR = Selection.Row
cp3sheet.Range("n1").Select
Do
If Cyclops = BG.Range("G2") Then Exit Do
FirstMemory = (FR) + MEMORYDistance
If UniqueLoop = 0 Then
SecondMemory = LR
ElseIf UniqueLoop <> 0 Then
SecondMemory = unique
Else
Return
End If
For ContactDate = (FirstMemory + 1) To SecondMemory
unique = cp3sheet.Cells(ContactDate, SC)
prevRow = cp3sheet.Cells(ContactDate - 1, SC)
prevRowRow = cp3sheet.Cells(ContactDate - 1, SC).Row
If unique <> prevRow Then
Counter = Format(Range(Cells(FirstMemory, 13), Cells(prevRowRow, 13)), "h:mm AM/PM;@") & vbTab & Range(Cells(FirstMemory, 1), Cells(prevRowRow, 1)) & _
vbTab & Range(Cells(FirstMemory, 2), Cells(prevRowRow, 2)) & vbTab & Range(Cells(FirstMemory, 3), Cells(prevRowRow, 3)) & vbNewLine & vbNewLine
returnDay = Day(prevRow)
returnMonth = Month(prevRow)
returnYear = Year(prevRow)
Dim OLApp As Outlook.Application
Dim olApt As AppointmentItem
Dim blnCreated As Boolean
Set OLApp = GetObject(, "Outlook.Application")
If OLApp Is Nothing Then
Set OLApp = CreateObject("Outlook.Application")
blnCreated = True
Err.Clear
Else
blnCreated = False
End If
On Error GoTo 0
Set olApt = OLApp.CreateItem(olAppointmentItem)
With olApt
.AllDayEvent = True
.Start = DateSerial(returnYear, returnMonth, returnDay)
.Subject = Range("N2")
.Body = Counter
.BusyStatus = olBusy
.ReminderMinutesBeforeStart = 0
.ReminderSet = False
.Save
End With
Set olApt = Nothing
Set OLApp = Nothing
MEMORYDistance = MEMORYDistance + SecondMemory - FirstMemory
Cyclops = Cyclops + 1
End If
Next ContactDate
Loop
MsgBox ("Cyclops")
End Sub
Thank you!
Sincerely,
Joel
Bookmarks