Exporting to another file format

rcb007

Board Regular
Joined
Nov 12, 2020
Messages
90
Office Version
  1. 365
Platform
  1. Windows
I have the following vba code that would take a column and export it to a txt. However when it runs, the formulas in the exported txt show as #REF!

I did a quick macro manually doing what I wanted and noticed the Paste was not a PasteSpecial. I added this and it still did not work, unless I have it in wrong.

thank you!

VBA Code:
Sub EXPORT()

Sheets("Sheet2").Cells(Sheets("Sheet2").Cells(Rows.Count, "A").End(xlUp).Row - 22, "A").Resize(23).Value = Sheets("Sheet3").Range("W19:W43").Value
Dim wb As Workbook
Dim saveFile As String
Dim WorkRng As Range
On Error Resume Next
Set WorkRng = Sheets("Sheet2").Range("AA1:AA24635")
Application.ScreenUpdating = True
Application.DisplayAlerts = False
Set wb = Application.Workbooks.Add
WorkRng.Copy
wb.Worksheets(1).Paste
'wb.Wroksheets(1).Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
 :=False, Transpose:=False
saveFile = Application.GetSaveAsFilename(FileFilter:="Text Files (*.txt), *.txt")
wb.SaveAs Filename:=saveFile, FileFormat:=xlTextPrinter, CreateBackup:=False
wb.Close
Application.CutCopyMode = False
Application.DisplayAlerts = True
Application.ScreenUpdating = False

End Sub
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
I added this and it still did not work, unless I have it in wrong.

VBA Code:
wb.Wroksheets(1).Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False
You have spelt WorkSheets wrong. Try...
VBA Code:
wb.WorkSheets(1).Cells(1,1).PasteSpecial xlValues
Change Paste destination to suit (top left cell of the range).
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,169
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top