Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default formating multiple excel .csv files ?

Hi all

I've a folder with about 100 subfolders all containing
around 10 .csv files. I need to format all these files
using the same formatting (remove some lines, distribute
some text to differnt columns etc) Question:

Is there any way I can for example set up a macro to do the
formatting I need but then automatically make it run
through all the csv file in the folder structure ?

I look forwart to any responses and appreciate any advice
on the topic.

Cheers
Gerry R

  #2   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default formating multiple excel .csv files ?

this is where the power of Excel macros come in.

Write a macro that first reads the contents of your dir
and creates an array of all the sub-dirs, then in each and
every subdir look for files with extension *.csv and for
each sub-dir create another array of file names. Then open
these one after the other manipulate the files the way you
want then save & close them.

I have done some thing similar, but I go through every
single dir and then combine the *.csv files into a single
master file.

The code should not take more than two days to build and
test. I have already given you the structure for your
code, not sure if you can find a model for free.

If you need more info dropme an email,
-Neil



-----Original Message-----
Hi all

I've a folder with about 100 subfolders all containing
around 10 .csv files. I need to format all these files
using the same formatting (remove some lines, distribute
some text to differnt columns etc) Question:

Is there any way I can for example set up a macro to do

the
formatting I need but then automatically make it run
through all the csv file in the folder structure ?

I look forwart to any responses and appreciate any advice
on the topic.

Cheers
Gerry R

.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default formating multiple excel .csv files ?

This saves as a workbook since it sounds like you might need a workbook
format to handle the changes your are making, but you can change the code
from SaveAs to just SAVE.With Application.FileSearch
.NewSearch
.LookIn = "C:\My Folder"
.SearchSubFolders = True
.FileName = ".CSV"
.FileType = msoFileTypeAllFiles
If .Execute() 0 Then
MsgBox "There were " & .FoundFiles.Count & _
" file(s) found."
For i = 1 To .FoundFiles.Count
set wkbk = workbooks.Open( .FoundFiles(i)) sPath =
wkbk.Path if Right(sPath,1) < "\" then _ sPath =
sPath & "\" sName = wkbk.Name sName =
left(sName,len(sName)-4) & ".xls" ' do your processing
' now save as a workbook wkbk.SaveAs Filename = FileName:=sPath &
sName, _ FileFormat:=xlWorkbookNormal wkbk.Close
SaveChanges:=False Next i
Else
MsgBox "There were no files found."
End If
End With-- Regards,Tom Ogilvy"Gerry Rigney"
wrote in message
...
Hi all

I've a folder with about 100 subfolders all containing
around 10 .csv files. I need to format all these files
using the same formatting (remove some lines, distribute
some text to differnt columns etc) Question:

Is there any way I can for example set up a macro to do the
formatting I need but then automatically make it run
through all the csv file in the folder structure ?

I look forwart to any responses and appreciate any advice
on the topic.

Cheers
Gerry R



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default formating multiple excel .csv files ?

I think Tom is pasting from notepad???

With Application.FileSearch
.NewSearch
.LookIn = "C:\My Folder"
.SearchSubFolders = True
.Filename = ".CSV"
.FileType = msoFileTypeAllFiles
If .Execute() 0 Then
MsgBox "There were " & .FoundFiles.Count & _
" file(s) found."
For i = 1 To .FoundFiles.Count
Set wkbk = Workbooks.Open(.FoundFiles(i))
sPath = wkbk.Path
If Right(sPath, 1) < "\" Then _
sPath = sPath & "\"
sName = wkbk.Name
sName = Left(sName, Len(sName) - 4) & ".xls"
' do your processing
' now save as a workbook
wkbk.SaveAs Filename:=sPath & sName, _
FileFormat:=xlWorkbookNormal
wkbk.Close SaveChanges:=False
Next i
Else
MsgBox "There were no files found."
End If
End With

Tom Ogilvy wrote:

This saves as a workbook since it sounds like you might need a workbook
format to handle the changes your are making, but you can change the code
from SaveAs to just SAVE.With Application.FileSearch
.NewSearch
.LookIn = "C:\My Folder"
.SearchSubFolders = True
.FileName = ".CSV"
.FileType = msoFileTypeAllFiles
If .Execute() 0 Then
MsgBox "There were " & .FoundFiles.Count & _
" file(s) found."
For i = 1 To .FoundFiles.Count
set wkbk = workbooks.Open( .FoundFiles(i)) sPath =
wkbk.Path if Right(sPath,1) < "\" then _ sPath =
sPath & "\" sName = wkbk.Name sName =
left(sName,len(sName)-4) & ".xls" ' do your processing
' now save as a workbook wkbk.SaveAs Filename = FileName:=sPath &
sName, _ FileFormat:=xlWorkbookNormal wkbk.Close
SaveChanges:=False Next i
Else
MsgBox "There were no files found."
End If
End With-- Regards,Tom Ogilvy"Gerry Rigney"
wrote in message
...
Hi all

I've a folder with about 100 subfolders all containing
around 10 .csv files. I need to format all these files
using the same formatting (remove some lines, distribute
some text to differnt columns etc) Question:

Is there any way I can for example set up a macro to do the
formatting I need but then automatically make it run
through all the csv file in the folder structure ?

I look forwart to any responses and appreciate any advice
on the topic.

Cheers
Gerry R


--

Dave Peterson

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default formating multiple excel .csv files ?

thanks to you all.

unfortunatly macros are not something I've ever really
done, guess now is the time to start learning.

cheers again
Gerry
-----Original Message-----
Hi all

I've a folder with about 100 subfolders all containing
around 10 .csv files. I need to format all these files
using the same formatting (remove some lines, distribute
some text to differnt columns etc) Question:

Is there any way I can for example set up a macro to do the
formatting I need but then automatically make it run
through all the csv file in the folder structure ?

I look forwart to any responses and appreciate any advice
on the topic.

Cheers
Gerry R

.

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
Convert multiple excel files with multiple sheets to PDF - how? Phil J W Excel Discussion (Misc queries) 3 November 5th 09 02:16 PM
export multiple sheets to multiple excel files Tanya Excel Discussion (Misc queries) 1 April 20th 09 08:57 PM
merge multiple worksheets from multiple excel files into oneworksheet Shamoun Ilyas Excel Discussion (Misc queries) 5 November 19th 08 09:48 PM
Multiple Excel files Mike Excel Worksheet Functions 1 June 12th 08 09:58 PM
Formating excel multiple paragraphs and colums using one source of data linux konqueror in progress Charts and Charting in Excel 0 October 15th 07 12:38 PM


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