VBA - generate csv from cells

0

I want to generate a CSV file from the 3-column data, but they present me with an error, could they help me?

Follow the code below:

Sub GravaTXT()

    Dim wbkExport As Workbook

    Dim shtToExport As Worksheet

    Dim name As String

    name = Range("R13").Value
    Set shtToExport = ThisWorkbook.Worksheets("Orcamento")

    ActiveColumn.Range("B").Select

    ActiveColumn.Range("M").Select

    ActiveColumn.Range("R").Select

    Set wbkExport = Application.Workbooks.Add

    shtToExport.Copy Before:=wbkExport.Worksheets(wbkExport.Worksheets.Count)

    Application.DisplayAlerts = False

    wbkExport.SaveAs Filename:="C:\Users\alcir.scarmin\Desktop\" & name & ".csv", FileFormat:=xlCSV

    Application.DisplayAlerts = True
    wbkExport.Close SaveChanges:=False

End Sub
    
asked by anonymous 11.09.2017 / 16:04

0 answers