Question : VBA Pase Special

I have looked at all the examples and cannot get them to work!!!!

I want to save a range as a CSV file by copying the range to a new work book and saving it as a csv file - Simple eh ?

What is wrong with this code ?

John
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
Private Sub XLtoCSV()
    Set shtData = ActiveSheet
    Set wbkDest = Workbooks.Add
    shtData.Range("$A$48").CurrentRegion.Copy
      
    'ActiveSheet.Range("a1").PasteSpecial Paste:=xlPasteValuesAndNumberFormats


    ActiveSheet.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
    xlNone, SkipBlanks:=False, Transpose:=False
 

    Application.DisplayAlerts = False

    wbkDest.SaveAs Filename:="C:\nv\MPGAllocation.csv", FileFormat:=xlCSV
    wbkDest.Close True
    Application.DisplayAlerts = True



End Sub

Answer : VBA Pase Special

Try this:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
Private Sub XLtoCSV()
    Set shtData = ActiveSheet
    Set wbkDest = Workbooks.Add
    shtData.Range("$A$48").CurrentRegion.Copy

    Application.ScreenUpdating = False
      
    'ActiveSheet.Range("a1").PasteSpecial Paste:=xlPasteValuesAndNumberFormats


    wbkDest.Sheet1.Select
    wbkDest.Sheet1.Range("A1").PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
    xlNone, SkipBlanks:=False, Transpose:=False
 

    Application.DisplayAlerts = False

    wbkDest.SaveAs Filename:="C:\nv\MPGAllocation.csv", FileFormat:=xlCSV
    wbkDest.Close True
    Application.DisplayAlerts = True
    Application.ScreenUpdating = True



End Sub
Random Solutions  
 
programming4us programming4us