Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default copy and save as csv

I have data in col a to e:
I would like a macro that would copy all the data(all the way to the bottom) and then save that data as a CSV file.
I would appreciate any help I can get with this
Thanks
Ian M
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,872
Default copy and save as csv

Hi Ian,

Am Sun, 28 Apr 2013 06:43:21 -0700 (PDT) schrieb pcorcele:

I have data in col a to e:
I would like a macro that would copy all the data(all the way to the bottom) and then save that data as a CSV file.


try:
Sub SaveAsCSV()
Dim WbkName As String
Dim myPath As String

WbkName = "Test"
myPath = "C:\Users\Claus Busch\Desktop\"
Sheets("Tabelle1").Copy
ActiveWorkbook.SaveAs Filename:=myPath & WbkName & ".csv", _
FileFormat:=xlCSV, CreateBackup:=False
ActiveWorkbook.Close
End Sub


Regards
Claus Busch
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 538
Default copy and save as csv

pcorcele wrote:

I have data in col a to e:
I would like a macro that would copy all the data(all the way to the
bottom) and then save that data as a CSV file.
I would appreciate any help I can get with this


If you only have data in the range A:E, I'd say use Claus' solution. But if
you have data outside those columns that you don't want exported, you might
try this instead:

Sub copyA_EtoCSV()
fileout = FreeFile
Open "data.csv" For Output As fileout
For r = 1 To Range("A:E").SpecialCells(xlCellTypeLastCell).Row
Write #fileout, Cells(r, 1).Value, Cells(r, 2).Value, _
Cells(r, 3).Value, Cells(r, 4).Value, Cells(r, 5).Value
Next
Close fileout
End Sub

(This will also work if there's only data in A:E like Claus' code, but this
makes sure that anything beyond column E isn't exported, regardless.)

In both Claus' code and mine above, the path for the CSV needs to be set
appropriately. (Claus shows how to do it based on where the workbook is; I
use a fixed location.)

--
Sorry if I'm in this business to make the world a better place,
not out of misplaced guilt.
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default copy and save as csv

On Sunday, April 28, 2013 9:43:21 AM UTC-4, pcorcele wrote:
I have data in col a to e:

I would like a macro that would copy all the data(all the way to the bottom) and then save that data as a CSV file.

I would appreciate any help I can get with this

Thanks

Ian M


Thanks for all the help.I did try your suggestions......But I found out that I did not give you all the info required. Using your suggestions, copied the ENTURE file. My file consists of THREE sheets. I just want to copy the first sheet which is called MYMOVIES. I would appreciate any help with this
and thanks
Ian M
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,872
Default copy and save as csv

Hi Ian,

Am Mon, 29 Apr 2013 06:52:43 -0700 (PDT) schrieb pcorcele:

Thanks for all the help.I did try your suggestions......But I found out that I did not give you all the info required. Using your suggestions, copied the ENTURE file. My file consists of THREE sheets. I just want to copy the first sheet which is called MYMOVIES. I would appreciate any help with this
and thanks


change the line with copy to:
Sheets("MYMOVIES").Copy


Regards
Claus Busch
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2
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
save a copy Opal Excel Programming 3 November 26th 09 04:13 PM
Save a copy? George W. Barrowcliff Excel Worksheet Functions 0 March 12th 07 12:00 AM
want to save a copy as text , not save the original as text Janis Excel Programming 4 December 1st 06 05:40 AM
Save column J only using copy/paste & temporary copy mikeburg[_85_] Excel Programming 2 June 7th 06 05:37 PM
How to save a file without overwrite or save a copy? SettingChange Setting up and Configuration of Excel 1 November 3rd 05 02:10 AM


All times are GMT +1. The time now is 02:25 PM.

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

About Us

"It's about Microsoft Excel"