VBA code works on PC but not on Mac.

anushatamby

New Member
Joined
Mar 13, 2013
Messages
8
Hi all,

Can any of you please help me figure out how I can get the below code ( works perfectly on a PC) to work on a Mac?
The code works to update the DestWB with all sheets from the sourceWB. This code is used in the DestWb and references the path and file name of the Source to update its sheets. Thanks so much! any help will be greatly appreciated.

Private Sub Workbook_OpenT()


Dim sourceWB As Workbook
Dim destWB As Workbook
Dim ws, dws As Worksheet
Workbooks.Open Filename:=ThisWorkbook.Sheets("nodelete").Range("A2").Value & "\" & ThisWorkbook.Sheets("nodelete").Range("B2").Value
Workbooks(ThisWorkbook.Sheets("nodelete").Range("B2").Value).Activate
Set sourceWB = Workbooks(ThisWorkbook.Sheets("nodelete").Range("B2").Value)
Set destWB = ThisWorkbook
Application.ScreenUpdating = False
Application.DisplayAlerts = False
For Each ws In sourceWB.Worksheets
For Each dws In destWB.Worksheets
If ws.Name = dws.Name Then
dws.Delete
End If
Next dws
ws.Copy after:=destWB.Sheets(destWB.Sheets.Count)
Next ws
Application.DisplayAlerts = True
Application.ScreenUpdating = True
'Copy all the sheet in the workbook




End Sub
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Replace this line:
Code:
Filename:=ThisWorkbook.Sheets("nodelete").Range("A2").Value & "\" & ThisWorkbook.Sheets("nodelete").Range("B2").Value
with this:
Code:
Filename:=ThisWorkbook.Sheets("nodelete").Range("A2").Value & Application.PathSeparator & ThisWorkbook.Sheets("nodelete").Range("B2").Value
 
Upvote 0

Forum statistics

Threads
1,203,435
Messages
6,055,353
Members
444,781
Latest member
rishivar

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