Re: Excel Macro by OfficeGuyGoesWild
OfficeGuyGoesWild
Tue Nov 07 20:29:58 CST 2006
Hi Scott,
It is possible to do all of this with VBScript. For problems like this
it is best to break down the problem into a series of smaller tasks.
You can then write these down as section headings which later become
the comments for your script.. like this:
' Define Constants
' Instantiate Objects
' Populate Variables
' Get Folder
' Loop through folder to get list of files
' Open each File
' Loop through each line in file
' Test for text
' If specific text found then writeline to excel
' Close Text File and open next
' Save Excel File
' Close Excel object
' Tidy Up
Each of these steps are easier to manage than the one whole, and over
time you can reuse code from one project for another, especially if you
set some standards for yourself with things like variable naming [
strComputer], and object naming [ objFso] etc.
Also it is good to use Functions for common tasks like writing to
Excel, Looping though a list of files etc.
. Let me know if you want specifics on how to do the above tasks.
..Marty
www.TheScriptLibrary.com
Ray Costanzo [MVP] wrote:
> Yes it is. What part are you stuck on? Looping through files? Open an
> Excel file? Searching through a worksheet? Creating a new file? Something
> else?
>
> Ray at work
>
> "Scott" <Scott@discussions.microsoft.com> wrote in message
> news:7B4F35FF-BA6E-457C-B18F-A9ACDF3D65F0@microsoft.com...
> > Hi
> >
> > I have a folder with a large list of files. I need a macro that goes
> > through
> > each file and searches for a specific number ( a clients FNN). I then need
> > it
> > to copy all of the information from this row into a new document and then
> > paste the information. The information from each file needs to be on a new
> > line.
> >
> > Is it possible to write this in VBS?
> >
> > Thanks in advance