title: Excel for Mac, User-select, Import CSV to specific sheet
body: <p>I'm having quite some trouble building a macro that will let a user select a CSV and then have it imported into a specific worksheet.</p>
  
  <p>I've found <a href="http://www.mrexcel.com/forum/excel-questions/753082-user-prompt-import-csv-mac.html" rel="nofollow">this script</a>, which imports a user-selected file into a new workbook, and tried to modify it for my needs - But without luck so far..</p>
  
  <p>This is my script so far:</p>
  
  <pre><code>    Sub Select_File_Or_Files_Mac()
      Dim MyPath As String
      Dim MyScript As String
      Dim MyFiles As String
      Dim MySplit As Variant
      Dim N As Long
      Dim NR As Long
      Dim Fname As String
      Dim mybook As Excel.Workbook
      Dim mysheet As Excel.Worksheet
  
      On Error Resume Next
      MyPath = MacScript("return (path to documents folder) as String")
      'Or use MyPath = "Macintosh HD:Users:YourUserName:Desktop:TestFolder:"
  
      MyScript = "set applescript's text item delimiters to (ASCII character 10) " &amp; vbNewLine &amp; _
              "set theFiles to (choose file of type " &amp; _
            " (""public.comma-separated-values-text"") " &amp; _
              "with prompt ""Please select a file or files"" default location alias """ &amp; _
              MyPath &amp; """ multiple selections allowed true) as string" &amp; vbNewLine &amp; _
              "set applescript's text item delimiters to """" " &amp; vbNewLine &amp; _
              "return theFiles"
  
      MyFiles = MacScript(MyScript)
      On Error GoTo 0
  
      If MyFiles &lt;&gt; "" Then
          With Application
              .ScreenUpdating = False
              .EnableEvents = False
          End With
      MySplit = Split(MyFiles, Chr(10))
          For N = LBound(MySplit) To UBound(MySplit)
  
              'Get file name only and test if it is open
              Fname = Right(MySplit(N), Len(MySplit(N)) - InStrRev(MySplit(N), _
              Application.PathSeparator, , 1))
  
                  On Error Resume Next
                  Set mysheet = ThisWorkbook.Sheets("Rapport")
                  On Error GoTo 0
               Next
  
  Worksheets("Rapport").Activate
  
  NR = mysheet.Range("A" &amp; Rows.Count).End(xlUp).Row + 1
  
  With mysheet.QueryTables.Add(Connection:="TEXT;" &amp; Fname, _
          Destination:=mysheet.Range("A" &amp; NR))
          .Name = "CSV" &amp; Worksheets.Count + 1
          .FieldNames = True
          .RowNumbers = False
          .FillAdjacentFormulas = False
          .RefreshOnFileOpen = False
          .BackgroundQuery = True
          .RefreshStyle = xlInsertDeleteCells
          .SavePassword = False
          .SaveData = True
          .AdjustColumnWidth = True
          .TextFilePromptOnRefresh = False
          .TextFilePlatform = xlMacintosh
          .TextFileStartRow = 1
          .TextFileParseType = xlDelimited
          .TextFileTextQualifier = xlTextQualifierDoubleQuote
          .TextFileConsecutiveDelimiter = True
          .TextFileTabDelimiter = True
          .TextFileSemicolonDelimiter = False
          .TextFileCommaDelimiter = True
          .TextFileSpaceDelimiter = True
          .TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
  End With
  
                End If
  
  End Sub
  </code></pre>
  
  <p>Note: The sheet into where the CSV should be inserted is called "Rapport" atm.</p>
  
  <p>Right now I'm using a Apple Script beforehand to run through the CSV and replace ";" with "," - So any way of implementing this as well, would be highly appreciated!</p>
  
  <p>Thanks!</p>