Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
writing macros in excel sheet | Excel Worksheet Functions | |||
writing macros in excel | Excel Programming | |||
Writing Excel Macros in VB.NET/C# | Excel Programming | |||
Need help writing basic macros in EXCEL.. | Excel Discussion (Misc queries) | |||
Writing Macros in Excel | Excel Programming |