Advertisement
YasserKhalil2019

T3965_Export To New Workbook Set New Invoice

Sep 22nd, 2019
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. https://excel-egy.com/forum/t3965
  2. ---------------------------------
  3.  
  4. Sub Export_To_New_Workbook_Set_New_Invoice()
  5. Dim fw, wb As Workbook, ws As Worksheet, d As Integer
  6.  
  7. d = MsgBox("هل تريد حفظ الفاتورة الحالية وعمل فاتورة جديدة؟", vbYesNo, "رسـالة من المبرمج ")
  8. If d = vbYes Then
  9. Application.ScreenUpdating = False
  10. Application.DisplayAlerts = False
  11. fw = "D:\Invoice\فاتورة المصنع رقم_" & Range("D6").Value & ".xlsm"
  12. ThisWorkbook.SaveCopyAs fw
  13. Set wb = Workbooks.Open(fw)
  14.  
  15. With wb
  16. For Each ws In wb.Worksheets
  17. If ws.Name <> "Sheet1" Then ws.Delete
  18. Next ws
  19. With wb.Worksheets(1)
  20. On Error Resume Next
  21. .Columns("I:L").Delete
  22. .Shapes("Rounded Rectangle 6").Delete
  23. On Error GoTo 0
  24. End With
  25. wb.Close True
  26. End With
  27.  
  28. With ThisWorkbook.Worksheets("Sheet1")
  29. .Range("D6").Value = "00" & .Range("D6").Value + 1
  30. .Range("B13:E25").ClearContents
  31. End With
  32. Application.DisplayAlerts = True
  33. Application.ScreenUpdating = True
  34. Else
  35. MsgBox "لم يتم حفظ الفاتورة الحالية ولا عمل فاتورة جديدة", vbExclamation, "رسـالة من المبرمج "
  36. End If
  37. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement