Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default Macro to Saved Selected Excel data to .CSV format


Ok Gang, This is going to be a Hard one for you Smart people.

I need a Super powerful Macro so when i click on the macro it
automatically saves the chosen data as a .CSV file.

I'll Give you E.g.

I enter data (numbers,text) from Cell "A1" across to Cell "G1" and down
to "G12" then back to "A12" making a nice box full of Sexy data. Then
After all that data is entered i Click on my Super Powerful Macro and
it gets all that information and saves it into a .csv file somewhere
esle. So in the end i would have my normal Excel doc and my New .csv
doc.......

If anyone can help me with this you will be the smartest person alive.


--
joelbeveridge
------------------------------------------------------------------------
joelbeveridge's Profile: http://www.excelforum.com/member.php...o&userid=37045
View this thread: http://www.excelforum.com/showthread...hreadid=567765

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Macro to Saved Selected Excel data to .CSV format

How about:

Option Explicit
Sub testme()
Dim myRng As Range
Dim wks As Worksheet

Set myRng = Selection

'create a new workbook with a single sheet
Set wks = Workbooks.Add(1).Worksheets(1)

myRng.Copy
wks.Range("a1").PasteSpecial Paste:=xlPasteValues

With wks.Parent
Application.DisplayAlerts = False
.SaveAs Filename:="C:\temp\mynamehere.csv", FileFormat:=xlCSV
Application.DisplayAlerts = True
.Close savechanges:=False
End With
End Sub


Change the name and folder to what you want.

And select the range to save before you run the macro.

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

joelbeveridge wrote:

Ok Gang, This is going to be a Hard one for you Smart people.

I need a Super powerful Macro so when i click on the macro it
automatically saves the chosen data as a .CSV file.

I'll Give you E.g.

I enter data (numbers,text) from Cell "A1" across to Cell "G1" and down
to "G12" then back to "A12" making a nice box full of Sexy data. Then
After all that data is entered i Click on my Super Powerful Macro and
it gets all that information and saves it into a .csv file somewhere
esle. So in the end i would have my normal Excel doc and my New .csv
doc.......

If anyone can help me with this you will be the smartest person alive.

--
joelbeveridge
------------------------------------------------------------------------
joelbeveridge's Profile: http://www.excelforum.com/member.php...o&userid=37045
View this thread: http://www.excelforum.com/showthread...hreadid=567765


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default Macro to Saved Selected Excel data to .CSV format


OK Dave I used your really cool code to allow me to Save the data i
wanted to a .CSV file somewhere on my PC. I changed it alittle to suit
my needs. I made the macro and when i clicked on the marco it makes the
.CSV file but there is no data in it. Have a look at what i changed.
Thanks mate


Option Explicit
Sub ConvertToCsv()


Dim myRng As Range
Dim wks As Worksheet

Set myRng = Selection

'create a new workbook with a single sheet
Set wks = Workbooks.Add(1).Worksheets(1)

myRng.Copy
wks.Range("n11:w33").PasteSpecial Paste:=xlPasteValues

With wks.Parent
Application.DisplayAlerts = False
.SaveAs Filename:="C:\testfolder\converted.csv", FileFormat:=xlCSV
Application.DisplayAlerts = True
.Close savechanges:=False
End With
End Sub

Any Infomation you can help me with???


--
joelbeveridge
------------------------------------------------------------------------
joelbeveridge's Profile: http://www.excelforum.com/member.php...o&userid=37045
View this thread: http://www.excelforum.com/showthread...hreadid=567765

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Macro to Saved Selected Excel data to .CSV format

Check to see what's in your current selection--is there data in that range?

And change this line back:
wks.Range("n11:w33").PasteSpecial Paste:=xlPasteValues
to
wks.Range("a1").PasteSpecial Paste:=xlPasteValues



joelbeveridge wrote:

OK Dave I used your really cool code to allow me to Save the data i
wanted to a .CSV file somewhere on my PC. I changed it alittle to suit
my needs. I made the macro and when i clicked on the marco it makes the
CSV file but there is no data in it. Have a look at what i changed.
Thanks mate

Option Explicit
Sub ConvertToCsv()

Dim myRng As Range
Dim wks As Worksheet

Set myRng = Selection

'create a new workbook with a single sheet
Set wks = Workbooks.Add(1).Worksheets(1)

myRng.Copy
wks.Range("n11:w33").PasteSpecial Paste:=xlPasteValues

With wks.Parent
Application.DisplayAlerts = False
SaveAs Filename:="C:\testfolder\converted.csv", FileFormat:=xlCSV
Application.DisplayAlerts = True
Close savechanges:=False
End With
End Sub

Any Infomation you can help me with???

--
joelbeveridge
------------------------------------------------------------------------
joelbeveridge's Profile: http://www.excelforum.com/member.php...o&userid=37045
View this thread: http://www.excelforum.com/showthread...hreadid=567765


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Macro to Saved Selected Excel data to .CSV format

just to expand...

wks.range("a1") is the topleft cell of that new worksheet.

All the code is doing is copying your selection and pasting (as values) to that
top left cell (excel will expand the number of columns/rows to match the range
being copied).

Then it's saving that newly created file as a .csv file.

Dave Peterson wrote:

Check to see what's in your current selection--is there data in that range?

And change this line back:
wks.Range("n11:w33").PasteSpecial Paste:=xlPasteValues
to
wks.Range("a1").PasteSpecial Paste:=xlPasteValues

joelbeveridge wrote:

OK Dave I used your really cool code to allow me to Save the data i
wanted to a .CSV file somewhere on my PC. I changed it alittle to suit
my needs. I made the macro and when i clicked on the marco it makes the
CSV file but there is no data in it. Have a look at what i changed.
Thanks mate

Option Explicit
Sub ConvertToCsv()

Dim myRng As Range
Dim wks As Worksheet

Set myRng = Selection

'create a new workbook with a single sheet
Set wks = Workbooks.Add(1).Worksheets(1)

myRng.Copy
wks.Range("n11:w33").PasteSpecial Paste:=xlPasteValues

With wks.Parent
Application.DisplayAlerts = False
SaveAs Filename:="C:\testfolder\converted.csv", FileFormat:=xlCSV
Application.DisplayAlerts = True
Close savechanges:=False
End With
End Sub

Any Infomation you can help me with???

--
joelbeveridge
------------------------------------------------------------------------
joelbeveridge's Profile: http://www.excelforum.com/member.php...o&userid=37045
View this thread: http://www.excelforum.com/showthread...hreadid=567765


--

Dave Peterson


--

Dave Peterson


  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default Macro to Saved Selected Excel data to .CSV format


Well i changed myRng.Copy
wks.Range("a1").PasteSpecial Paste:=xlPasteValues back to ("a1") as you
told me. The thing im finding is that its only tranfering things to .CSV
if i highlight them then click on the macro. I would like if it
automatically copied the data i only want between "N11" and "W32".

So at the moment it only converts data to .csv format if i go and drag
my mouse over it and then press the macro. Any clue how i can make it
smarter?


--
joelbeveridge
------------------------------------------------------------------------
joelbeveridge's Profile: http://www.excelforum.com/member.php...o&userid=37045
View this thread: http://www.excelforum.com/showthread...hreadid=567765

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
PAUSE EXCEL MACRO FOR INPUT OF DATA VARIABLE lynne b Excel Discussion (Misc queries) 3 September 11th 06 03:37 PM
In EXCEL 2002 format cell with existing data. greg1090 Excel Discussion (Misc queries) 1 July 19th 06 10:51 PM
Numbers/Text data missing from excel to excel query? RAMAERTE Excel Discussion (Misc queries) 0 May 8th 06 05:05 PM
Retrieve data from separate Excel session JessK Charts and Charting in Excel 2 March 27th 06 01:34 AM
Help PLEASE! Not sure what answer is: Match? Index? Other? baz Excel Worksheet Functions 7 September 3rd 05 03:47 PM


All times are GMT +1. The time now is 07:06 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"