VBA Edit to Copy all but Sheet2 AND...

Alex O

Active Member
Joined
Mar 16, 2009
Messages
345
Office Version
  1. 365
Platform
  1. Windows
I have my code mostly complete - except for a few minor edits that have me stumped! I need all sheets copied to the new workbook except Sheet2 (ODBC_TABLE). If possible, I'd also like no headings and password protected. Any help would be appreciated. Thanks

Code:
Sub New_Syscofile()
    Dim Output As Workbook
    Dim Current As String
    Dim FileName As String
    Set Output = ThisWorkbook
    Current = ThisWorkbook.FullName
    Application.DisplayAlerts = False
    Dim SH As Worksheet
    For Each SH In Output.Worksheets
        SH.UsedRange.Copy
        SH.UsedRange.PasteSpecial xlPasteValues, _
            Operation:=xlNone, SkipBlanks:=True, Transpose:=False
    Next
    FileName = ThisWorkbook.Path & "\" & "SYSCO MIDWEST INV" & Format(Date, "mmddyyyy")
    Output.SaveAs FileName, XlFileFormat.xlOpenXMLWorkbook
    Workbooks.Open Current
    Application.DisplayAlerts = True
    ActiveWindow.DisplayHeadings = False
    ActiveWindow.Zoom = 90
End Sub
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Hi Alex0

Have you tried recording a macro performing each task –
Start recording:
selecting each required sheet, copy into a new workbook.
Stop recording.
In the new work book Start recording:
Add password to required sheets/book.
Stop recording.

Then look at the macros you have recorded and see what processesyou can use i.e. the line for selecting each required sheet, passwordprotecting a sheet/book. Then adding those to your final macro.
Sorry I cannot be of more help.

 
Upvote 0

Forum statistics

Threads
1,223,901
Messages
6,175,277
Members
452,629
Latest member
SahilPolekar

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