Advertisement
Guest User

Untitled

a guest
Oct 28th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. Dim app As New Excel.Application
  2. app.Visible = False
  3.  
  4. Set newWB = app.Workbooks.Add
  5. With newWB
  6. .Title = "Summarizing of systemparts information"
  7. .Subject = "Systemparts"
  8. .SaveAs assembledSheet
  9. End With
  10.  
  11. app.newWB.Sheets("SystemParts").ListObjects.Add(xlSrcRange, Range("$A$1:$CN$55"), , xlYes).Name = "SystemP"
  12. app.ActiveSheet.ListObjects("SystemP").TableStyle = "TableStyleLight8"
  13.  
  14. Sub Test()
  15.  
  16. Dim app As Excel.Application
  17. Dim newWB As Workbook
  18. Dim newWS As Worksheet
  19. Dim x As Long
  20.  
  21. 'Create new Excel instance and add a new workbook.
  22. Set app = New Excel.Application
  23. Set newWB = app.Workbooks.Add
  24.  
  25. With newWB
  26. 'Add a sheet to the end of the workbook.
  27. Set newWS = .Worksheets.Add(, .Worksheets(.Worksheets.Count))
  28.  
  29. 'Remove all other sheets.
  30. 'As you delete sheet Index 1 - the next sheet replaces it,
  31. 'so just remove the first index each time.
  32. Application.DisplayAlerts = False
  33. For x = 1 To .Worksheets.Count - 1
  34. .Worksheets(1).Delete
  35. Next x
  36. Application.DisplayAlerts = True
  37.  
  38. 'Name the new sheet and add a table.
  39. With newWS
  40. .Name = "SystemParts"
  41. .ListObjects.Add(xlSrcRange, .Range("$A$1:$CN$55"), , xlYes).Name = "SystemP"
  42. .ListObjects("SystemP").TableStyle = "TableStyleLight8"
  43. End With
  44.  
  45. .SaveAs ThisWorkbook.Path & "NewWB.xlsx"
  46.  
  47.  
  48. End With
  49.  
  50. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement