VBA - generate csv from cells

Asked

Viewed 468 times

0

I am wanting to generate a CSV file from the data of 3 columns, but they presents me an error, could help me?

Follows 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
  • Which error?

  • It presents me "Error 424 the object and mandatory"

  • On which line is this error shown ?

  • Resolved, thank you!

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.