Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
DMB DMB is offline
external usenet poster
 
Posts: 14
Default Network drive problems

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Network drive problems

DMB

I tested your code (the first part) and it worked fine for me?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Network drive problems

You sure that's the correct path?

And just a question:
Wouldn't it be better to loop through those two workbooks--just in case you had
more workbooks open:

For Each file In Workbooks
If UCase(file.Name) < "PERSONAL.XLS" Then


For i = 1 to 2
For Each sht In workbooks(filename(i)).Worksheets




DMB wrote:

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


--

Dave Peterson
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
Network drive Greg Excel Worksheet Functions 1 January 13th 10 04:22 AM
map network drive lumpy04 Excel Discussion (Misc queries) 1 March 15th 07 05:31 PM
Save to Network Drive Problems. Expanding Current code mcgrad Excel Programming 3 January 25th 06 02:21 PM
Link workbooks-C drive to network drive Earl Excel Worksheet Functions 0 April 19th 05 05:50 PM
Userform Local Drive & Network drive question Joel Mills Excel Programming 3 December 29th 04 10:43 PM


All times are GMT +1. The time now is 01:41 AM.

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"