Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.setup
external usenet poster
 
Posts: 5
Default Macro to create new files

I have a .csv file with a single column of data. I want to create a separate
..csv file for each cell in the column utilizing a macro since there are over
600 cells in the row. Any advice on how to create this macro to automate the
process?

Thanks in advance.
  #2   Report Post  
Posted to microsoft.public.excel.setup
external usenet poster
 
Posts: 5
Default Macro to create new files

Sorry - make that 600 cells in the column.


"btrotter" wrote:

I have a .csv file with a single column of data. I want to create a separate
.csv file for each cell in the column utilizing a macro since there are over
600 cells in the row. Any advice on how to create this macro to automate the
process?

Thanks in advance.

  #3   Report Post  
Posted to microsoft.public.excel.setup
external usenet poster
 
Posts: 35,218
Default Macro to create new files

So you want each value in it's own .csv file?

Option Explicit
Sub testme()

Dim FileNum As Long
Dim myRng As Range
Dim myCell As Range

With Worksheets("sheet1")
Set myRng = .Range("a1", .Cells(.Rows.Count, "A").End(xlUp))
End With

FileNum = FreeFile
Close #FileNum

For Each myCell In myRng.Cells
Open "C:\temp\" & Format(myCell.Row, "0000") & ".CSV" _
For Output As FileNum
Print #FileNum, myCell.Text
Close #FileNum
Next myCell

End Sub

(Make sure that "C:\temp\" already exists (or change the code to a folder that
does exist.)



btrotter wrote:

Sorry - make that 600 cells in the column.

"btrotter" wrote:

I have a .csv file with a single column of data. I want to create a separate
.csv file for each cell in the column utilizing a macro since there are over
600 cells in the row. Any advice on how to create this macro to automate the
process?

Thanks in advance.


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.setup
external usenet poster
 
Posts: 22,906
Default Macro to create new files

You want 600+ csv files with the data from 1 cell in each file?

Assuming you have a C:\mycsv folder

Open the *,csv file in Excel, make sure your data is in Sheet1 then run this
macro.

You can add the macro to the open workbook or to your Personal.xls

Sub Make_New_Books()
Dim rng As Range
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Set rng = ActiveSheet.Range(Range("A1"), Range("A" & Rows.Count). _
End(xlUp).Address)
For Each cell In rng
cell.Copy
Workbooks.Add
With ActiveWorkbook
.Sheets("Sheet1").Range("A1").Value = cell.Value
.SaveAs Filename:="C:\mycsv" & "\" & cell.Value, FileFormat:=xlCSV, _
CreateBackup:=False
.Close
End With
Next cell
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub


Gord Dibben MS Excel MVP


On Wed, 14 Nov 2007 09:12:02 -0800, btrotter
wrote:

I have a .csv file with a single column of data. I want to create a separate
.csv file for each cell in the column utilizing a macro since there are over
600 cells in the row. Any advice on how to create this macro to automate the
process?

Thanks in advance.


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
create .xlk files maryj Excel Discussion (Misc queries) 5 May 18th 07 06:10 PM
Macro to create a folder and copy files GainesvilleWes New Users to Excel 2 February 26th 07 06:33 PM
Macro to create mulitple files Consulting Joan Excel Discussion (Misc queries) 1 February 8th 06 03:38 AM
Create individual files from a row GrahamN Excel Discussion (Misc queries) 3 July 4th 05 10:01 PM
Why does Excel in XP create new files? Lindy Excel Discussion (Misc queries) 3 December 2nd 04 12:56 AM


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