delete some sheets of new workbook

Ambiguooous

New Member
Joined
Jun 6, 2018
Messages
30
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
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
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
 
Upvote 0
.. 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?
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,224,828
Messages
6,181,210
Members
453,023
Latest member
alabaz

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top