Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Dim app As New Excel.Application
- app.Visible = False
- Set newWB = app.Workbooks.Add
- With newWB
- .Title = "Summarizing of systemparts information"
- .Subject = "Systemparts"
- .SaveAs assembledSheet
- End With
- app.newWB.Sheets("SystemParts").ListObjects.Add(xlSrcRange, Range("$A$1:$CN$55"), , xlYes).Name = "SystemP"
- app.ActiveSheet.ListObjects("SystemP").TableStyle = "TableStyleLight8"
- Sub Test()
- Dim app As Excel.Application
- Dim newWB As Workbook
- Dim newWS As Worksheet
- Dim x As Long
- 'Create new Excel instance and add a new workbook.
- Set app = New Excel.Application
- Set newWB = app.Workbooks.Add
- With newWB
- 'Add a sheet to the end of the workbook.
- Set newWS = .Worksheets.Add(, .Worksheets(.Worksheets.Count))
- 'Remove all other sheets.
- 'As you delete sheet Index 1 - the next sheet replaces it,
- 'so just remove the first index each time.
- Application.DisplayAlerts = False
- For x = 1 To .Worksheets.Count - 1
- .Worksheets(1).Delete
- Next x
- Application.DisplayAlerts = True
- 'Name the new sheet and add a table.
- With newWS
- .Name = "SystemParts"
- .ListObjects.Add(xlSrcRange, .Range("$A$1:$CN$55"), , xlYes).Name = "SystemP"
- .ListObjects("SystemP").TableStyle = "TableStyleLight8"
- End With
- .SaveAs ThisWorkbook.Path & "NewWB.xlsx"
- End With
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement