Sembra strano in quanto il range viene caricato bene, prova comunque a sostituire tutto il codice con questo:
(in pratica ho cambiato solo le prime righe prima del ciclo for modifcando il modo in cui il range viene preso)
Option Explicit
Sub AggiornaScadenze_VF()
Dim v As Variant
Dim OutApp As Object
Dim fdrCalendar As Object
Dim ItemAppt As Object
Dim i As Long
Dim j As Long
Dim bFound As Boolean
Dim rng As Range
Dim lastRow As Integer
Set OutApp = CreateObject("Outlook.Application")
Set fdrCalendar = OutApp.GetNamespace("MAPI").GetDefaultFolder(9) '9 = olFolderCalendar
OutApp.Session.Logon
Sheets("Foglio1").Select 'Nome del foglio excel
lastRow = Range("A" & Rows.Count).End(xlUp).Row
Set rng = Range("A1:C" & lastRow)
rng.Select
For Each v In rng
If v.Row > 1 Then
If Trim(v.Cells(3)) = "" Then
MsgBox "Il documento " & v.Cells(1) & " non ha una data scadenza", vbInformation, "campo obbligatorio"
Else
'---- check
For Each ItemAppt In fdrCalendar.Items
If ItemAppt.Subject = v.Cells(1) Then
bFound = True
'Trovato subject uguale: verifico se il corpo è uguale, se diverso lo aggiorno
If ItemAppt.Body <> v.Cells(2) Then
ItemAppt.Body = v.Cells(2)
ItemAppt.Save
j = j + 1
End If
'Data di scadenza non uguale all'appuntamento già inserito:
'Cancella appuntamento esistente e lo reinserisce in nuova posizione
If ItemAppt.Start <> v.Cells(3) Then
ItemAppt.Delete
Call CreateItem(OutApp, v)
j = j + 1
End If
'Data di scadenza è = TDB in excel e all'appuntamento già inserito:
'Cancella appuntamento esistente
If v.Cells(3) = "TBD" Then
ItemAppt.Delete
j = j + 1
End If
End If
Next
'--------------------
If Not bFound Then
Call CreateItem(OutApp, v)
i = i + 1
bFound = False
End If
End If
End If
Next
Set OutApp = Nothing
MsgBox "Ho inserito " & i & " scadenze, ho modificato " & j & " scadenze"
End Sub
Private Sub CreateItem(olApp As Object, v As Variant)
Dim OutCalendar As Object
Set OutCalendar = olApp.CreateItem(1) 'Nuovo appuntamento
With OutCalendar
.AllDayEvent = True
.Start = v.Cells(3) 'Data scadenza
.Subject = v.Cells(1) 'tipo documento
.Body = v.Cells(2) 'note documento
.ReminderMinutesBeforeStart = 50 'Applica quanti minuti prima deve inviare il Reminder della scadenza
.ReminderSet = False 'Non applica il Reminder alla scadenza
'.Recipients.Add ("******@prova.it;******@prova.it")
.Save
'.Send
End With
Set OutCalendar = Nothing
End Sub
Ho salvato anche il file condiviso, dovresti avere il codice anche li.
E' un tentativo per capire cosa succede, non dovrebbe cambiare molto.
Fammi sapere,
Daniele