Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]() 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
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]() 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
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]() 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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
PAUSE EXCEL MACRO FOR INPUT OF DATA VARIABLE | Excel Discussion (Misc queries) | |||
In EXCEL 2002 format cell with existing data. | Excel Discussion (Misc queries) | |||
Numbers/Text data missing from excel to excel query? | Excel Discussion (Misc queries) | |||
Retrieve data from separate Excel session | Charts and Charting in Excel | |||
Help PLEASE! Not sure what answer is: Match? Index? Other? | Excel Worksheet Functions |