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
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