1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
Function sms_non_envoyes()
Dim str, LePath As String
Dim Dl2, x As Long
' récupération nombre lignes non vides dans la page DATA pour extraire à partir de la ligne suivante
With ws
Dl = ws.Range("T" & ws.Rows.Count).End(xlUp).Row
Set WBsms = Workbooks.Add
WBsms.SaveAs Filename:=ThisWorkbook.Path & "\SMS NON ENVOYES DU " & Format(Now(), "dd mm yy") & ".xlsx"
' boucle allant de 1 jusqu'à la dernière ligne non vide de la feuille DATA
For x = Dl To 1 Step -1
Dl2 = WBsms.Sheets(1).Range("A" & ws.Rows.Count).End(xlUp).Row
' si la cellule en T1 ... Tx est vide alors on copie la ligne entière dans le fichier wb_sms_non_envoyes
str = ws.Range("T" & x)
If ws.Range("T" & x) = "" Then
ws.Rows(x).Cut Destination:=WBsms.Sheets(1).Rows(Dl2 + 1)
ws.Rows(x).Delete
Else
LePath = Dir("P:\PROG CREATION SMS\SMS NON ENVOYES DU " & Format(Now(), "dd mm yy") & ".xlsx")
Do While LePath <> ""
Kill "P:\PROG CREATION SMS\" & LePath
LePath = Dir
Loop
'suppression
End If
Next x
End With
WBsms.Save
WBsms.Close
End Function |
Partager