G
Guest
How do I write the code correctly. The following program won't find the
network drive.
Is there somthing worng with this line?
FilePath = "\\TW Design Server\TW Engineering\DMB Time\"
Private Sub btnCalculate_Click()
TotalHoursToDate.Text = 0
Dim FilePath As String
FilePath = "C:\My Programs\"
FilePath = "\\TW Design Server\TW Engineering\DMB Time\"
Dim FileName(2) As String
FileName(1) = "Time Card 2005.xls"
FileName(2) = "Time Card 2006.xls"
For i = 1 To 2
Workbooks.Open FileName:=FilePath & FileName(i), ReadOnly:=True
Next i
Dim file As Workbook
Dim sht As Worksheet
Dim cel As Range
Dim j As Integer
Dim Total As Double
Total = 0
For Each file In Workbooks
If UCase(file.Name) <> "PERSONAL.XLS" Then
For Each sht In file.Worksheets
For Each cel In sht.Range("F1:F30")
If sht.Cells(cel.Row, cel.Column).Text =
TotalHours.Projects.Text Then
Total = Total + Round(sht.Cells(cel.Row, cel.Column
- 1), 2)
End If
Next cel
Next sht
End If
Next file
TotalHoursToDate.Text = Total
End Sub
network drive.
Is there somthing worng with this line?
FilePath = "\\TW Design Server\TW Engineering\DMB Time\"
Private Sub btnCalculate_Click()
TotalHoursToDate.Text = 0
Dim FilePath As String
FilePath = "C:\My Programs\"
FilePath = "\\TW Design Server\TW Engineering\DMB Time\"
Dim FileName(2) As String
FileName(1) = "Time Card 2005.xls"
FileName(2) = "Time Card 2006.xls"
For i = 1 To 2
Workbooks.Open FileName:=FilePath & FileName(i), ReadOnly:=True
Next i
Dim file As Workbook
Dim sht As Worksheet
Dim cel As Range
Dim j As Integer
Dim Total As Double
Total = 0
For Each file In Workbooks
If UCase(file.Name) <> "PERSONAL.XLS" Then
For Each sht In file.Worksheets
For Each cel In sht.Range("F1:F30")
If sht.Cells(cel.Row, cel.Column).Text =
TotalHours.Projects.Text Then
Total = Total + Round(sht.Cells(cel.Row, cel.Column
- 1), 2)
End If
Next cel
Next sht
End If
Next file
TotalHoursToDate.Text = Total
End Sub