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