delete some sheets of new workbook

Ambiguooous

New Member
Joined
Jun 6, 2018
Messages
25
How can I delete some sheets from the new generated workbook if I am using the following code :


Sub SaveAsValues()
Dim ws As Worksheet


For Each ws In Worksheets
ws.UsedRange.Value = ws.UsedRange.Value
Next ws

ThisWorkbook.SaveAs "D:\LM - " & Format(Date, "dd mmmm yyyy"), _
FileFormat:=51, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, CreateBackup:=False
End Sub
 

Some videos you may like

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple

Peter_SSs

MrExcel MVP, Moderator
Joined
May 28, 2005
Messages
46,165
Office Version
  1. 365
Platform
  1. Windows
Which sheets do you want deleted?
 

Ambiguooous

New Member
Joined
Jun 6, 2018
Messages
25
This workbook consists of 10 sheets (8 related to customers) and there are 2 related to data "raw data"

what i want to generate a new workbook with only 8 sheets without any formula to send it to the concerned
 

Peter_SSs

MrExcel MVP, Moderator
Joined
May 28, 2005
Messages
46,165
Office Version
  1. 365
Platform
  1. Windows
.. there are 2 related to data "raw data" ..
1. So is it these 2 sheets that you want deleted?

2. If so, how do we identify them? Do they have particular tab names? or are they always, say, the left hand 2 sheets in the workbook? or something else we can use to logically identify which ones have to be deleted?
 

Peter_SSs

MrExcel MVP, Moderator
Joined
May 28, 2005
Messages
46,165
Office Version
  1. 365
Platform
  1. Windows
yes yes we can identify them, their names : ( prices ) & ( codes )
Try adding the blue code where shown

Rich (BB code):
For Each ws In Worksheets
  ws.UsedRange.Value = ws.UsedRange.Value
Next ws
Application.DisplayAlerts = False
Sheets("prices").Delete
Sheets("codes").Delete
Application.DisplayAlerts = True
 

Watch MrExcel Video

Forum statistics

Threads
1,108,654
Messages
5,524,114
Members
409,561
Latest member
ay123

This Week's Hot Topics

Top