Spike69
08-03-2007, 07:09 AM
This is my primary program......
Sub Program()
'
'Creates Variables to be used in the program
'
Dim i, k, j As Integer
Dim myFile, mypath, Fichiers(1000), NomCompose, UniteCompose, Avg As String
Dim NbComposes, Lignetravail, InfoTypeNumber, NBFichier, _
NbResultats, DataRows As Double
Dim Nomdufichier, nomfichier As String
Dim File As Object
Dim R As Long
Dim C, Rng As Range
'Dim wks As Workbook
'
' Creates a path to open the DataEchantillon File
'
myPath2 = "D:\Documents and Settings\pw41203\Desktop\Eric\Excel_Program\DataEchantillon"
'
' Opens the DataEchantillon file
'
Workbooks.Open Filename:=myPath2
Lignetravail = 2
'
'Counts how many .xls files are in the folder called Analyze
'
myFile = Dir("C:\conv\Analyze\*.xls")
mypath = "C:\conv\Analyze\"
i = 0
Do While myFile <> ""
i = i + 1
Fichiers(i) = myFile
myFile = Dir
Loop
NBFichier = i
'
'Creates a for loop in order to open Analyze file(s) and to determine the file name
'
For i = 1 To NBFichier
'
'Opens Analyze file
'
Nomdufichier = mypath & Fichiers(i)
Workbooks.Open (Nomdufichier)
nomfichier = Cells(2, 1)
'
' Find how many components are contained through the Range("B3" To "E3") in the Analyze files
'
NbComposes = 1
Do While Cells(1, NbComposes + 2) <> ""
NbComposes = NbComposes + 1
Loop
For j = 1 To Nbcompose
NomCompose = Cells(1, j + 1)
UniteCompose = Cells(2, j + 1)
Next j
' Combine les resultats des basses de donner
For k = 1 To NbResultats
'
' Calculer l' infotype de l' analyse
'
InfoTypeNumber = 10000 + nomfichier * 10 + j
'
'
' Copies the result, and the Dates from Analyze files
' Copies values to "DataEchantillon.xls" File
'
Lignetravail = Lignetravail + 1
End If
Next k
Next i
'
' Closes the File
'
End Sub
Sub Program()
'
'Creates Variables to be used in the program
'
Dim i, k, j As Integer
Dim myFile, mypath, Fichiers(1000), NomCompose, UniteCompose, Avg As String
Dim NbComposes, Lignetravail, InfoTypeNumber, NBFichier, _
NbResultats, DataRows As Double
Dim Nomdufichier, nomfichier As String
Dim File As Object
Dim R As Long
Dim C, Rng As Range
'Dim wks As Workbook
'
' Creates a path to open the DataEchantillon File
'
myPath2 = "D:\Documents and Settings\pw41203\Desktop\Eric\Excel_Program\DataEchantillon"
'
' Opens the DataEchantillon file
'
Workbooks.Open Filename:=myPath2
Lignetravail = 2
'
'Counts how many .xls files are in the folder called Analyze
'
myFile = Dir("C:\conv\Analyze\*.xls")
mypath = "C:\conv\Analyze\"
i = 0
Do While myFile <> ""
i = i + 1
Fichiers(i) = myFile
myFile = Dir
Loop
NBFichier = i
'
'Creates a for loop in order to open Analyze file(s) and to determine the file name
'
For i = 1 To NBFichier
'
'Opens Analyze file
'
Nomdufichier = mypath & Fichiers(i)
Workbooks.Open (Nomdufichier)
nomfichier = Cells(2, 1)
'
' Find how many components are contained through the Range("B3" To "E3") in the Analyze files
'
NbComposes = 1
Do While Cells(1, NbComposes + 2) <> ""
NbComposes = NbComposes + 1
Loop
For j = 1 To Nbcompose
NomCompose = Cells(1, j + 1)
UniteCompose = Cells(2, j + 1)
Next j
' Combine les resultats des basses de donner
For k = 1 To NbResultats
'
' Calculer l' infotype de l' analyse
'
InfoTypeNumber = 10000 + nomfichier * 10 + j
'
'
' Copies the result, and the Dates from Analyze files
' Copies values to "DataEchantillon.xls" File
'
Lignetravail = Lignetravail + 1
End If
Next k
Next i
'
' Closes the File
'
End Sub