Bekijk de onderstaande video om te zien hoe je onze site als een web app op je startscherm installeert.
Opmerking: Deze functie is mogelijk niet beschikbaar in sommige browsers.
Privacywetgeving
Het is bij Helpmij.nl niet toegestaan om persoonsgegevens in een voorbeeld te plaatsen. Alle voorbeelden die persoonsgegevens bevatten zullen zonder opgaaf van reden verwijderd worden. In de vraag zal specifiek vermeld moeten worden dat het om fictieve namen gaat.
Enkel wat voor voordeel heeft dit voor VBA, dat het allemaal op één sheet gebeurt ?
Sub Mail_on_DateHSV()
Dim EmailSubject As String
Dim EmailSendTo As String
Dim MailBody As String
sn = Sheets("Documenten_registratie").Cells(1).CurrentRegion.Resize(, 18)
For j = 2 To UBound(sn)
For x = j To UBound(sn)
If sn(x, 6) = sn(j, 6) And sn(x, 17) = "" Then
sn(x, 17) = "verstuurd"
sn(x, 18) = Date
For jj = 7 To 16
If sn(x, jj) <> "" And DateDiff("d", Date, sn(x, jj)) < 31 Then
c00 = c00 & IIf(InStr(c00, sn(x, 2)) = 0, vbLf & sn(x, 1) & " " & sn(x, 2) & vbLf, "") & sn(1, jj) & ", vervallen of vervalt op datum : " & sn(x, jj) & vbLf
End If
Next jj
End If
Next x
If c00 <> "" Then
'Subject string
EmailSubject = "Aanvraag productspecificatie cq Certificaten"
[B][/B][COLOR="#FF0000"] EmailSendTo = Sheets("leverancier").Cells(Application.Match(sn(j, 4), Sheets("Leverancier").Columns(1), 0), 3)
Emailtav = Sheets("leverancier").Cells(Application.Match(sn(j, 4), Sheets("Leverancier").Columns(1), 0), 2)[/COLOR]
'Send Mail
With CreateObject("Outlook.Application").createitem(0)
.Subject = EmailSubject
.To = EmailSendTo
'.Bcc =
.body = "Beste " & Emailtav & "," & vbNewLine & vbNewLine _
& "Volgens onze administratie van onze BRC, zijn er certificaten verlopen. Hieronder ziet u een overzicht van de verlopen certificaten: " & vbLf & c00 & vbNewLine & "Wij willen u dan ook vragen deze geldige certificaten ons toe te sturen zodat wij deze gegevens juist hebben voor onze BRC" & vbNewLine & vbNewLine & "Met vriendelijke groet," & vbNewLine & vbNewLine & "BRC Team" & vbNewLine & "leveranciernaam"
.Display
'.send
End With
c00 = ""
End If
Cells(1).CurrentRegion.Resize(, 18) = sn
Next j
End Sub
EmailSendTo = Sheets("Documenten_registratie").Cells(Application.Match(sn(j, 4), Sheets("Documenten_registratie").Columns(1), 0), 5)
Emailtav = Sheets("Documenten_registratie").Cells(Application.Match(sn(j, 4), Sheets("Documenten_registratie").Columns(1), 0), 6)
Sub Mail_on_DateHSVNieuw()
Dim EmailSubject As String
Dim EmailSendTo As String
Dim MailBody As String
sn = Sheets("Documenten_registratie").Cells(1).CurrentRegion.Resize(, 17)
For j = 2 To UBound(sn)
For x = j To UBound(sn)
If sn(x, 5) = sn(j, 5) And sn(x, 16) = "" Then
For jj = 6 To 15
If sn(x, jj) <> "" And DateDiff("d", Date, sn(x, jj)) < 31 Then
sn(x, 16) = "verstuurd"
sn(x, 17) = Date
c00 = c00 & IIf(InStr(c00, sn(x, 2)) = 0, vbLf & sn(x, 1) & " " & sn(x, 2) & vbLf, "") & "- " & sn(1, jj) & ", is vervallen of vervalt op datum : " & sn(x, jj) & " , uw nummer : " & sn(x, 3) & vbLf
End If
Next jj
End If
Next x
If c00 <> "" Then
'Subject string
EmailSubject = "Aanvraag productspecificatie cq Certificaten"
EmailSendTo = Sheets("leverancier").Cells(Application.Match(sn(j, 4), Sheets("Leverancier").Columns(1), 0), 3)
Emailtav = Sheets("leverancier").Cells(Application.Match(sn(j, 4), Sheets("Leverancier").Columns(1), 0), 2)
'Send Mail
With CreateObject("Outlook.Application").createitem(0)
.Subject = EmailSubject
.To = EmailSendTo
'.Bcc =
.body = "Beste " & Emailtav & "," & vbNewLine & vbNewLine _
& "Volgens onze administratie zijn onderstaande BRC certificaten verlopen." & vbLf & c00 & vbNewLine & "Wij willen u dan ook vragen om ons binnen 14 dagen nieuwe geldige certificaten toe te sturen." & vbNewLine & "Bij voorbaat dank voor uw medewerking." & vbNewLine & vbNewLine & "Met vriendelijke groet," & vbNewLine & vbNewLine & "BRC Team" & vbNewLine & "ZNP Verpakkingen BV"
.Display
'.send
End With
c00 = ""
End If
Cells(1).CurrentRegion.Resize(, 17) = sn
Next j
Cells(1).CurrentRegion.Resize(, 17) = sn
Sub Mail_on_DateHSVNieuw2()
Application.ScreenUpdating = False
Dim EmailSubject As String
Dim EmailSendTo As String
Dim MailBody As String
sn = Sheets("Documenten_registratie").Cells(1).CurrentRegion.Resize(, 17)
For j = 2 To UBound(sn)
For x = j To UBound(sn)
If sn(x, 5) = sn(j, 5) And sn(x, 16) = "" Then
For jj = 6 To 15
If sn(x, jj) <> "" And DateDiff("d", Date, sn(x, jj)) < 31 Then
sn(x, 16) = "verstuurd"
sn(x, 17) = Date
[COLOR="#FF0000"]If Emailtaal = "NL" Then
c00 = c00 & IIf(InStr(c00, sn(x, 2)) = 0, vbLf & sn(x, 1) & " " & sn(x, 2) & vbLf, "") & "- " & sn(1, jj) & ", is vervallen of vervalt op datum : " & sn(x, jj) & " , uw nummer : " & sn(x, 3) & vbLf
Else
c00 = c00 & IIf(InStr(c00, sn(x, 2)) = 0, vbLf & sn(x, 1) & " " & sn(x, 2) & vbLf, "") & "- " & sn(1, jj) & ", has expired or will expire on date : " & sn(x, jj) & " , your number : " & sn(x, 3) & vbLf
End If[/COLOR]
End If
Next jj
End If
Next x
If c00 <> "" Then
'Subject string
EmailSubject = "Aanvraag productspecificatie cq Certificaten"
EmailSendTo = Sheets("leverancier").Cells(Application.Match(sn(j, 4), Sheets("Leverancier").Columns(1), 0), 3)
Emailtav = Sheets("leverancier").Cells(Application.Match(sn(j, 4), Sheets("Leverancier").Columns(1), 0), 2)
[COLOR="#FF0000"] Emailtaal = Sheets("leverancier").Cells(Application.Match(sn(j, 4), Sheets("Leverancier").Columns(1), 0), 4)[/COLOR]
'Send Mail
With CreateObject("Outlook.Application").createitem(0)
.Subject = EmailSubject
.To = EmailSendTo
[COLOR="#FF0000"]If Emailtaal = "NL" Then
.body = "Beste " & Emailtav & "," & vbNewLine & vbNewLine _
& "Volgens onze administratie zijn onderstaande BRC certificaten verlopen." & vbLf & c00 & vbNewLine & "Wij willen u dan ook vragen om ons binnen 14 dagen nieuwe geldige certificaten toe te sturen." & vbNewLine & "Bij voorbaat dank voor uw medewerking." & vbNewLine & vbNewLine & "Met vriendelijke groet," & vbNewLine & vbNewLine & "BRC Team" & vbNewLine & "Bedrijfsnaam"
Else
.body = "Dear " & Emailtav & "," & vbNewLine & vbNewLine _
& "According to our administration are the below BRC certificates expired." & vbLf & c00 & vbNewLine & "We want to ask you to send us new valid certificates within 14 days." & vbNewLine & "Thanks in advance for your cooperation." & vbNewLine & vbNewLine & "Sincerely," & vbNewLine & vbNewLine & "BRC Team" & vbNewLine & "Bedrijfsnaam"
End If[/COLOR]
.Display
End With
c00 = ""
End If
Cells(1).CurrentRegion.Resize(, 17) = sn
Next j
End Sub
Code:Sub Mail_on_DateHSVNieuw2() Application.ScreenUpdating = False Dim EmailSubject As String Dim EmailSendTo As String Dim MailBody As String sn = Sheets("Documenten_registratie").Cells(1).CurrentRegion.Resize(, 17) For j = 2 To UBound(sn) For x = j To UBound(sn) If sn(x, 5) = sn(j, 5) And sn(x, 16) = "" Then For jj = 6 To 15 If sn(x, jj) <> "" And DateDiff("d", Date, sn(x, jj)) < 31 Then sn(x, 16) = "verstuurd" sn(x, 17) = Date [COLOR=#3366ff] Emailtaal = Sheets("leverancier").Cells(Application.Match(sn(j, 4), Sheets("Leverancier").Columns(1), 0), 4)[/COLOR] [COLOR=#FF0000]If Emailtaal = "NL" Then c00 = c00 & IIf(InStr(c00, sn(x, 2)) = 0, vbLf & sn(x, 1) & " " & sn(x, 2) & vbLf, "") & "- " & sn(1, jj) & ", is vervallen of vervalt op datum : " & sn(x, jj) & " , uw nummer : " & sn(x, 3) & vbLf Else c00 = c00 & IIf(InStr(c00, sn(x, 2)) = 0, vbLf & sn(x, 1) & " " & sn(x, 2) & vbLf, "") & "- " & sn(1, jj) & ", has expired or will expire on date : " & sn(x, jj) & " , your number : " & sn(x, 3) & vbLf End If[/COLOR] End If Next jj End If Next x If c00 <> "" Then 'Subject string EmailSubject = "Aanvraag productspecificatie cq Certificaten" EmailSendTo = Sheets("leverancier").Cells(Application.Match(sn(j, 4), Sheets("Leverancier").Columns(1), 0), 3) Emailtav = Sheets("leverancier").Cells(Application.Match(sn(j, 4), Sheets("Leverancier").Columns(1), 0), 2) 'Send Mail With CreateObject("Outlook.Application").createitem(0) .Subject = EmailSubject .To = EmailSendTo [COLOR=#FF0000]If Emailtaal = "NL" Then .body = "Beste " & Emailtav & "," & vbNewLine & vbNewLine _ & "Volgens onze administratie zijn onderstaande BRC certificaten verlopen." & vbLf & c00 & vbNewLine & "Wij willen u dan ook vragen om ons binnen 14 dagen nieuwe geldige certificaten toe te sturen." & vbNewLine & "Bij voorbaat dank voor uw medewerking." & vbNewLine & vbNewLine & "Met vriendelijke groet," & vbNewLine & vbNewLine & "BRC Team" & vbNewLine & "Bedrijfsnaam" Else .body = "Dear " & Emailtav & "," & vbNewLine & vbNewLine _ & "According to our administration are the below BRC certificates expired." & vbLf & c00 & vbNewLine & "We want to ask you to send us new valid certificates within 14 days." & vbNewLine & "Thanks in advance for your cooperation." & vbNewLine & vbNewLine & "Sincerely," & vbNewLine & vbNewLine & "BRC Team" & vbNewLine & "Bedrijfsnaam" End If[/COLOR] .Display End With c00 = "" End If Cells(1).CurrentRegion.Resize(, 17) = sn Next j End Sub
We gebruiken essentiële cookies om deze site te laten werken, en optionele cookies om de ervaring te verbeteren.