Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default writing excel macros

Hello! I am not sure if I need to edit the existing macro, but here is the
deal: I have an Excel spreadsheet which runs a macro to save as a csv
document. Is there a way I can edit the macro or something I need to do
elsewhere so that the csv will only display data from Excel rows with data?
Right now I get my Excel data in the csv and followed by pages of just commas
from rows without data. Thank you very much for your help and your time. If
you are explaining any editing to macros, please use baby-steps as I have not
worked with any sort of macro writing before. The one I have is pre-existing
by another user (no longer available to me to help).
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 415
Default writing excel macros

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

NickHK

"TMiGNa" ...
Hello! I am not sure if I need to edit the existing macro, but here is
the
deal: I have an Excel spreadsheet which runs a macro to save as a csv
document. Is there a way I can edit the macro or something I need to do
elsewhere so that the csv will only display data from Excel rows with
data?
Right now I get my Excel data in the csv and followed by pages of just
commas
from rows without data. Thank you very much for your help and your time.
If
you are explaining any editing to macros, please use baby-steps as I have
not
worked with any sort of macro writing before. The one I have is
pre-existing
by another user (no longer available to me to help).



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default writing excel macros

"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



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 415
Default writing excel macros

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





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default writing excel macros

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








  #6   Report Post  
Posted to microsoft.public.excel.programming
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
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default writing excel macros

Check that cells in Excel do not contain spaces or some other non printing
characters.
You may get some extra blank columns, because of the way Excel parses the
data (in blocks of 16 rows), but this should not affect the whole row.

NickHK

"TMiGNa" wrote in message
...
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








Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
writing macros in excel sheet Richard Buttrey Excel Worksheet Functions 7 May 10th 06 01:04 AM
writing macros in excel jaffar Excel Programming 1 May 5th 06 02:06 PM
Writing Excel Macros in VB.NET/C# [email protected] Excel Programming 0 January 19th 06 04:02 AM
Need help writing basic macros in EXCEL.. Macro Help Excel Discussion (Misc queries) 1 March 8th 05 02:28 PM
Writing Macros in Excel Shannon Excel Programming 6 August 13th 04 07:58 PM


All times are GMT +1. The time now is 08:59 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"