Hello
well you see i have this exact code in an other sheet and that one works fine but with this code i get and error message: Next without For
why do i get that message? the fault comes up in second last row of the code
Private Sub Workbook_Open()
Dim i As Long
Dim OutApp As Object
Dim OutMail As Object
Dim strto As String, strcc As String, strbcc As String
Dim strsub As String, strbody As String
For i = 11 To Sheets("Garantilista").Range("B65536").End(xlUp).Row
If Sheets("Garantilista").Cells(i, 7).Value = DateSerial(Year(Date), Month(Date), Day(Date) + 21) Then
If Sheets("Garantilista").Cells(i, 8).Value = DateSerial(Year(Date), Month(Date), Day(Date) + 21) Then
If Sheets("Garantilista").Cells(i, 9).Value = DateSerial(Year(Date), Month(Date), Day(Date) + 21) Then
If Sheets("Garantilista").Cells(i, 10).Value = DateSerial(Year(Date), Month(Date), Day(Date) + 21) Then
If Sheets("Garantilista").Cells(i, 11).Value = DateSerial(Year(Date), Month(Date), Day(Date) + 21) Then
Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)
strto = Sheets("Garantilista").Cells(i, 12).Value
strcc = Sheets("Garantilista").Cells(i, 13).Value & _
"; " & Sheets("Garantilista").Cells(i, 14).Value
strbcc = ""
strsub = "Garantilista"
strbody = "Hej" & vbNewLine & vbNewLine & _
"Garanti/service besök till " & Sheets("Garantilista").Cells(i, 1).Value & _
" på adress:" & Sheets("Garantilista").Cells(i, 2).Cells(i, 3).Value & _
" kontaktperson för detta är: " & Sheets("Garantilista").Cells(i, 4).Value & _
" Telenr till kontaktperson: " & Sheets("Garantilista").Cells(i, 5).Value & _
vbCrLf & vbCrLf & " Är samtliga punkter från Slutbeskitning avhjälpta " & Sheets("Garantilista").Cells(i, 6).Value & _
vbCrLf & vbCrLf & "/Garantidatabasen Bravida Eskilstuna"
With OutMail
.To = strto
.CC = strcc
.BCC = strbcc
.Subject = strsub
.Body = strbody
.Send
End With
Set OutMail = Nothing
Set OutApp = Nothing
End If
Next i
End Sub
Bookmarks