Hi!
Following macro exports contents of entire worksheet of SheetC to a text file in a specific location. I need help to modify the macro to export data only from Columns I & K.
Option Explicit
Sub ExportData()
On Error Resume Next
Dim wbkExport As Workbook
Dim shtToExport As Worksheet
Set shtToExport = ThisWorkbook.Worksheets("SheetC")
Set wbkExport = Application.Workbooks.Add
shtToExport.Copy Before:=wbkExport.Worksheets(wbkExport.Worksheets.Count)
wbkExport.SaveAs Filename:="C:\Data\ExportData.txt", FileFormat:=xlTextMSDOS
wbkExport.Close SaveChanges:=False
End Sub
Kindly note the specific properties of the above code:
1. There are more than one worksheets in the workbook and when the macro is being run, SheetC will not be the active sheet in the foreground, so above macro needs to run in background;
2. I need to import the data in the .txt file for further processing in another excel file, so using the above specific file format.
3. The Data text file needs to be replaced automatically without prompts to replace or save or open the resulting file
Note: Sample File attached
Thanks
Bookmarks