Macro that previously worked now fails on latest version of Excel 365 for Mac

MJ79

New Member
Joined
Sep 28, 2021
Messages
3
Office Version
  1. 365
Platform
  1. MacOS
I've used a macro for several years on an earlier version of Excel for Mac.
The Excel version was 2011, and the Macro looks like this:

VBA Code:
Sub MOTM()
Dim ws As Worksheet, newWb As Workbook

Application.ScreenUpdating = False
For Each ws In Sheets(Array("6weekform", "MOTM"))
   ws.Copy
   Set newWb = ActiveWorkbook
   With newWb
      .SaveAs ws.Name & ".csv", xlCSVWindows
      .Close (False)
   End With
Next ws
Application.ScreenUpdating = True

End Sub

The Macro saved the workbook sheets "6weekform" and "MOTM" as two separate CSV files, keeping the original xlsm file separate.
Since recently moving to the new version of Excel 365 (16.53) for Mac (running Catalina 10.15.7), the Macro fails and produces this error:

Image

When I click on Debug, it highlights this part of the Macro:

Image

I can't find anywhere online that offers a solution for this, so any assistance any one can give me would be gratefully received.
I have several Macros like this one that used to produce dozens of CSV files from sheets, which I now have to individually manually save.
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Have you tried changing the file type to xlCSVMac?
Your code works in Windows as it should, unable to test on a Mac, but that would be my first suggestion.
 
Upvote 0
Thanks for trying, unfortunately same error, at the same point:

Screenshot 2021-11-17 at 09.17.29.png
 
Upvote 0
I ran your code in Windows multiple times, and received the query about each file already existing (which you will need to manage the user selecting 'No' to this), but then tried using Excel for Mac and received the same error as you. I normally only develop VBA in Windows, so not familiar with the differences using a Mac I'm afraid.
 
Upvote 0

Forum statistics

Threads
1,223,243
Messages
6,170,971
Members
452,371
Latest member
Frana

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