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

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
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,213,538
Messages
6,114,218
Members
448,554
Latest member
Gleisner2

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