View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default writing excel macros

Try resetting the used range before you create the .csv file.

Debra Dalgleish shows techniques to reset that last used cell:
http://contextures.com/xlfaqApp.html#Unused

TMiGNa wrote:

I'm still getting all the excess commas - sorry...

"NickHK" wrote:

Make a back up of your original file first, then replace your code with
this.
Does this achieve your aim ?

Sub Save_EF_as_csv()
Dim RetVal As Variant

Sheets("Electronic File").Copy
RetVal = Application.GetSaveAsFilename(, "CSV File (*.csv),*.csv", , "Select
a file name and location")
If RetVal = False Then Exit Sub

ActiveWorkbook.SaveAs RetVal, xlCSV
ActiveWorkbook.Close False

Sheets("Print File").Select
End Sub

NickHK

"TMiGNa" ...
"NickHK" wrote:

Post what you have at the moment, as long as it's not pages long.

NickHK
-----------------------------------------------------------------------------------------

Sub Save_EF_as_csv()
'
' Save_EF_as_csv Macro
' Macro recorded 2/4/2005 by KClifford
'

Sheets("Electronic File").Select
Cells.Select
Selection.Copy
Workbooks.Add
Selection.PasteSpecial Paste:=xlFormats, Operation:=xlNone,
SkipBlanks:= _
False, Transpose:=False
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:=
_
False, Transpose:=False
ActiveWorkbook.SaveAs Filename:=Application.GetSaveAsFilename(""),
FileFormat:= _
xlCSV
ActiveWindow.Close , SaveChanges:=False
Sheets("Print File").Select
End Sub







--

Dave Peterson