Macros Not working on MAC

linister

New Member
Joined
Jan 16, 2021
Messages
23
Office Version
  1. 2019
Platform
  1. Windows
Hi,
I have the following VBA that works fine on Windows but on mac it shows an issue with this Line:
.AllowMultiSelect = False

I believe it's because the folder selection process in Windows and Mac are different, therefor, can someone who knows their way around VBA kindly assist me in revising the following VBA to work on MAC:
VBA Code:
Option Explicit
Sub ExtractData()
    Dim directory, fileName As String
    Dim srcSheet, destSheet As Worksheet
    Dim fd As Office.FileDialog
    Dim item
    Dim masterWb, dataWb As Workbook
    Dim rng As Range
    Dim picPath As String
   
    picPath = "x"
    Set masterWb = ThisWorkbook
    Set fd = Application.FileDialog(msoFileDialogFilePicker)
    Call RemoveData
    With fd
        .AllowMultiSelect = False
        .Title = "Please select the file."
        .AllowMultiSelect = True
        .Filters.Clear
        .Filters.Add "Excel Files", "*.xlsx?"
       
    End With
   
    If fd.Show = True Then
        For Each item In fd.SelectedItems
            Workbooks.Open (Dir(item))
            Set dataWb = ActiveWorkbook
            For Each srcSheet In dataWb.Worksheets
                If srcSheet.Range("A2").Value <> "" Then
                    srcSheet.Copy after:=masterWb.Sheets(masterWb.Sheets.Count)
                    masterWb.Activate
                    Set destSheet = masterWb.Worksheets(masterWb.Worksheets.Count)
                    Set rng = destSheet.UsedRange
                    rng.Rows(1).Font.Color = vbBlack
                    rng.Rows(1).Font.Bold = True
                    rng.Rows(1).Interior.Color = RGB(180, 198, 231)
                    destSheet.UsedRange.Cut destSheet.Cells(1).Offset(4, 1)
                    destSheet.Activate
                    masterWb.Windows(1).DisplayGridlines = False
                    destSheet.UsedRange.Borders.LineStyle = xlContinuous
                    destSheet.Range("A1").ColumnWidth = 10
                    With destSheet.Range("B2")
                        .Value = destSheet.Name
                        .Font.Bold = True
                        .Font.Size = 14
                    End With
                    destSheet.UsedRange.EntireColumn.ColumnWidth = 50
                    With destSheet.Pictures.Insert(picPath)
                        With .ShapeRange
                            .LockAspectRatio = msoTrue
                            .Width = 50
                            .Height = 50
                        End With
                        .Placement = 1
                        .PrintObject = True
                    End With
                End If
            Next srcSheet
            dataWb.Close
        Next item
        masterWb.Worksheets("Main Sheet").Activate
    End If
   
End Sub

Sub RemoveData()
    Dim Ws As Worksheet
    Application.DisplayAlerts = False
    For Each Ws In Worksheets
        If Ws.Name <> "Main Sheet" Then Ws.Delete
    Next Ws
    Application.DisplayAlerts = True

End Sub
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).

Forum statistics

Threads
1,223,903
Messages
6,175,287
Members
452,631
Latest member
a_potato

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