Help with Excel macro

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

frankcase

Thread Starter
Joined
Feb 6, 2005
Messages
9
Hi,
I have been working on getting multiple files to open in excel and maybe even organise the data in the format i want. A number friends have helped and here is what I have:

Public Sub open_files()
Dim intIndex As Integer
Dim fsSearch As FileSearch
Dim fsoFile As FileSystemObject
Dim tsmContents As TextStream
Dim strPath As String
Dim wksSheet As Worksheet
Dim intCount As Integer
Dim fdDir As FileDialog

Application.ScreenUpdating = False
Application.DisplayAlerts = False
Set fdDir = Application.FileDialog(msoFileDialogFolderPicker)
fdDir.Show
fdDir.AllowMultiSelect = False
strPath = fdDir.SelectedItems(1)
Set fdDir = Nothing

Set fsoFile = New FileSystemObject
Set fsSearch = Application.FileSearch
fsSearch.LookIn = strPath
fsSearch.Filename = "*"
fsSearch.Execute
If fsSearch.FoundFiles.Count > 0 Then
For intIndex = 1 To fsSearch.FoundFiles.Count
intCount = 0
Set tsmContents = fsoFile.OpenTextFile(fsSearch.FoundFiles(intIndex))
Set wksSheet = ActiveWorkbook.Worksheets.Add
wksSheet.Name = fsoFile.GetFileName(fsSearch.FoundFiles(intIndex))
Do
Call Import_Contents(tsmContents.ReadLine, intCount)
intCount = intCount + 1
Loop Until tsmContents.AtEndOfStream
Next intIndex
End If

Set fsSearch = Nothing
Set wksSheet = Nothing
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub

The trouble is the code is not really working in my worksheet as I keep getting compile errors.

AS I described before, I want the macro to run, open a a dialog box so I can select a particular folder of data, The data in each file is added to one excel sheet and maybe organised in a more friendly format.

My second macro then does its magic on each sheet and graphs the data. I have yet to get the two macros running together. I am incluidng two separate files which should describe what i am trying to do.
Can anybody help.
Regards,
Frank
 

Attachments

frankcase

Thread Starter
Joined
Feb 6, 2005
Messages
9
Hi,
The error states sub or function not defined?
But I am also getting lots of red text on my code as well. Any help out there?
 
Joined
Sep 4, 2003
Messages
4,915
Which workbook and line of code throws the error? When I open the workbooks there is nothing highlighted in red.

Rollin
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Staff online

Top