Just for the sake of using arrays, next code will not use the clipboard. It is fast even for big ranges to be processed:
Sub ExportColumnsToCSV_Array()
Const sfRow As Long = 1
Const sColsList As String = "A:F,H:I,V,AM:AV"
Const dFirst As String = "A1"
Dim sCols() As String: sCols = Split(sColsList, ",")
Dim sws As Worksheet: Set sws = ActiveSheet
Dim swb As Workbook: Set swb = sws.Parent
Dim srrg As Range
Dim slCell As Range, arrCol, arr, lastRow As Long, lastCol As Long
If sws.UsedRange.cells.count <= 1 Then Exit Sub 'to avoid the next checking of lastRow and lastCol
With sws.rows(sfRow)
lastRow = .Resize(.Worksheet.rows.count - sfRow + 1) _
.Find("*", , xlFormulas, , xlByRows, xlPrevious).row 'last row of the range to be copied
End With
lastCol = ActiveSheet.Range("A1").SpecialCells(xlCellTypeLastCell).Column 'and its last column
arr = sws.Range("A1").Resize(lastRow, lastCol).value 'places the range to be copied in an array
'obtain array of necessary columns numbers:
arrCol = buildColAr(sColsList)
Debug.Print Join(arrCol, ","): 'just to see what array has been returned...
'Extract from the initial array only the necessary columns:
arr = Application.Index(arr, Application.Evaluate("row(1:" & lastRow & ")"), arrCol)
Dim dwb As Workbook: Set dwb = Application.Workbooks.Add
'drop the processed array result, at once:
dwb.Worksheets(1).Range(dFirst).Resize(UBound(arr), UBound(arr, 2)).value = arr
Dim dFolderPath As String: dFolderPath = swb.Path & "\Folder\"
If Dir(dFolderPath, vbDirectory) = "" Then MkDir dFolderPath
Dim dFilePath As String
dFilePath = dFolderPath & left(swb.Name, InStrRev(swb.Name, ".") - 1) & ".csv"
Application.DisplayAlerts = False
dwb.saveas FileName:=dFilePath, FileFormat:=xlCSVUTF8, Local:=False
dwb.Close SaveChanges:=False
Application.DisplayAlerts = True
End Sub
Private Function buildColAr(ByVal v As Variant) As Variant
Dim i&, temp, cols As Long, arrFilt, El, j As Long, k As Long
v = Split(v, ","): arrFilt = Filter(v, ":", True) 'in arrFilt will be kept the continuous ranges (like A:F)
For Each El In arrFilt
cols = cols + Range(El).Columns.count 'calculate the total number of columns to ReDim the array able to keep them
Next
ReDim temp(LBound(v) To UBound(v) - UBound(arrFilt) + cols - 1) 'Redim the necessary array to keep the columns number
For i = LBound(v) To UBound(v)
If InStr(v(i), ":") > 0 Then 'the case of adiacent columns ranges
For j = 1 To Range(v(i)).Columns.count
temp(k) = Range(v(i)).Columns(j).Column: k = k + 1
Next j
Else
temp(k) = cells(1, v(i)).Column: k = k + 1
End If
Next i
buildColAr = temp
End Function
Range("A1:AV" & Cells(Rows.Count, "A").End(xlUp).Row).Copy.ActiveWorkbook.ActiveSheet.UsedRange.CopywithRange("A1:AV" & Cells(Rows.Count, "A").End(xlUp).Row).Copy.