VBA - Select Multiple Worksheets - Excel 2016

rswarst

New Member
Joined
Aug 4, 2016
Messages
2
Hello,

I have a macro that broke down an Excel workbook into multiple saved files based on a sheet range, beginning with a defined sheet name and ending the sheet before another defined sheet name. I recently updated to Excel 2016 and the loop I have to select the sheets in the range is not working properly - it is only resulting in the last sheet being selected. The 'False' boolean after select sheets (which adds sheets to the current selection, instead of replacing) seems to not be followed. The macro was created and worked fine in Excel 2013.

Does anyone know what my issue could be? Here is the code to create one of the workbooks (starting with the Mid-Atlantic-F sheet and selecting all sheets up to the Florida-F sheet):

Private Sub MidAtlantic()

Sheets("Mid-Atlantic-F").Activate
ActiveSheet.Select

Do Until Sheets(ActiveSheet.Index + 1).Name = "Florida-F"
Sheets(ActiveSheet.Index + 1).Select False
Sheets(ActiveSheet.Index + 1).Activate

Loop

ActiveWindow.SelectedSheets.Copy
ActiveWorkbook.SaveAs Filename:="S:\Accounting Items\Monthly Reports\DistPL\Mid-Atlantic-PL.xlsx" _
, FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
ActiveWindow.Close
ActiveWindow.ScrollWorkbookTabs Position:=xlFirst
End Sub
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college

Forum statistics

Threads
1,215,254
Messages
6,123,893
Members
449,132
Latest member
Rosie14

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