Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
dd dd is offline
external usenet poster
 
Posts: 95
Default Advice to speed up process

I have a file index, which inputs the paths in various columns for
Autofiltering and makes the files into hyperlinks. It takes a while to
process (22 rows takes approx 2 mins to process). There will be more files
added as work proceeds. I want to know if there is a way to speed up the
process, I've tried Application.Screenupdating = True/False, but it seems to
take longer using this.
==
If oFolder.Files.Count 0 Then
For Each oFile In oFolder.Files
If oFile.Type = filetype Then

sFile = Mid(oFile.Path, 1)

'Start of first value iPos1 =
InStr(InStr(InStr(InStr(InStr(InStr(sFile, "\") + 1, sFile, "\") + 1, sFile,
"\") + 1, sFile, "\") + 1, sFile, "\") + 1, sFile, "\")
'End of first value and start of second value
iPos2 = InStr(InStr(InStr(InStr(InStr(InStr(InStr(sFile, "\") + 1,
sFile, "\") + 1, sFile, "\") + 1, sFile, "\") + 1, sFile, "\") + 1, sFile,
"\") + 1, sFile, "\")
'End of second value and start of third value
iPos3 = InStr(InStr(InStr(InStr(InStr(InStr(InStr(InStr(sF ile, "\") + 1,
sFile, "\") + 1, sFile, "\") + 1, sFile, "\") + 1, sFile, "\") + 1, sFile,
"\") + 1, sFile, "\") + 1, sFile, "\")
'End of third value
iPos4 = InStrRev(sFile, "\")

'first string
Cells(iFile, iPathColA).Value = Mid(sFile, iPos1 + 1, iPos2 - iPos1)

Cells(iFile, iPathColB).Value = Mid(sFile, iPos2 + 1, iPos3 - iPos2)

Cells(iFile, iPathColC).Value = Mid(sFile, iPos3 + 1, iPos4 - iPos3)

Cells(iFile, iFileCol) = oFile.Name

' And a link in the Hyperlink column
Cells(iFile, iLinkCol).FormulaR1C1 = "=HYPERLINK(root &
RC[-4] & RC[-3]& RC[-2] & RC[-1] ,""HERE"")"

iFile = iFile + 1
End If
Next oFile
End If


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Advice to speed up process

application.Calculation = xlManual
' current code
Application.Calculation = xlAutomatic

--
Regards,
Tom Ogilvy


"dd" wrote:

I have a file index, which inputs the paths in various columns for
Autofiltering and makes the files into hyperlinks. It takes a while to
process (22 rows takes approx 2 mins to process). There will be more files
added as work proceeds. I want to know if there is a way to speed up the
process, I've tried Application.Screenupdating = True/False, but it seems to
take longer using this.
==
If oFolder.Files.Count 0 Then
For Each oFile In oFolder.Files
If oFile.Type = filetype Then

sFile = Mid(oFile.Path, 1)

'Start of first value iPos1 =
InStr(InStr(InStr(InStr(InStr(InStr(sFile, "\") + 1, sFile, "\") + 1, sFile,
"\") + 1, sFile, "\") + 1, sFile, "\") + 1, sFile, "\")
'End of first value and start of second value
iPos2 = InStr(InStr(InStr(InStr(InStr(InStr(InStr(sFile, "\") + 1,
sFile, "\") + 1, sFile, "\") + 1, sFile, "\") + 1, sFile, "\") + 1, sFile,
"\") + 1, sFile, "\")
'End of second value and start of third value
iPos3 = InStr(InStr(InStr(InStr(InStr(InStr(InStr(InStr(sF ile, "\") + 1,
sFile, "\") + 1, sFile, "\") + 1, sFile, "\") + 1, sFile, "\") + 1, sFile,
"\") + 1, sFile, "\") + 1, sFile, "\")
'End of third value
iPos4 = InStrRev(sFile, "\")

'first string
Cells(iFile, iPathColA).Value = Mid(sFile, iPos1 + 1, iPos2 - iPos1)

Cells(iFile, iPathColB).Value = Mid(sFile, iPos2 + 1, iPos3 - iPos2)

Cells(iFile, iPathColC).Value = Mid(sFile, iPos3 + 1, iPos4 - iPos3)

Cells(iFile, iFileCol) = oFile.Name

' And a link in the Hyperlink column
Cells(iFile, iLinkCol).FormulaR1C1 = "=HYPERLINK(root &
RC[-4] & RC[-3]& RC[-2] & RC[-1] ,""HERE"")"

iFile = iFile + 1
End If
Next oFile
End If



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Advice to speed up process


Possibly the free Excel add-in List Files will do what you want.
Download from... http://www.realezsites.com/bus/primitivesoftware
No registration required.
--
Jim Cone
San Francisco, USA


"dd" <dd.dd wrote in message
I have a file index, which inputs the paths in various columns for
Autofiltering and makes the files into hyperlinks. It takes a while to
process (22 rows takes approx 2 mins to process). There will be more files
added as work proceeds. I want to know if there is a way to speed up the
process, I've tried Application.Screenupdating = True/False, but it seems to
take longer using this.
==
If oFolder.Files.Count 0 Then
For Each oFile In oFolder.Files
If oFile.Type = filetype Then
sFile = Mid(oFile.Path, 1)
'Start of first value iPos1 =
InStr(InStr(InStr(InStr(InStr(InStr(sFile, "\") + 1, sFile, "\") + 1, sFile,
"\") + 1, sFile, "\") + 1, sFile, "\") + 1, sFile, "\")
'End of first value and start of second value
iPos2 = InStr(InStr(InStr(InStr(InStr(InStr(InStr(sFile, "\") + 1,
sFile, "\") + 1, sFile, "\") + 1, sFile, "\") + 1, sFile, "\") + 1, sFile,
"\") + 1, sFile, "\")
'End of second value and start of third value
iPos3 = InStr(InStr(InStr(InStr(InStr(InStr(InStr(InStr(sF ile, "\") + 1,
sFile, "\") + 1, sFile, "\") + 1, sFile, "\") + 1, sFile, "\") + 1, sFile,
"\") + 1, sFile, "\") + 1, sFile, "\")
'End of third value
iPos4 = InStrRev(sFile, "\")

'first string
Cells(iFile, iPathColA).Value = Mid(sFile, iPos1 + 1, iPos2 - iPos1)
Cells(iFile, iPathColB).Value = Mid(sFile, iPos2 + 1, iPos3 - iPos2)
Cells(iFile, iPathColC).Value = Mid(sFile, iPos3 + 1, iPos4 - iPos3)
Cells(iFile, iFileCol) = oFile.Name
' And a link in the Hyperlink column
Cells(iFile, iLinkCol).FormulaR1C1 = "=HYPERLINK(root &
RC[-4] & RC[-3]& RC[-2] & RC[-1] ,""HERE"")"
iFile = iFile + 1
End If
Next oFile
End If


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Advice to speed up process

Instead of using all those Instr's, use Split

Dim sFile As String
Dim PathParts() As String
Dim Temp As String

sFile = oFile.Path

PathParts = Split(sFile, "\")

Cells(iFile, iPathColA).Value = PathParts(0) & "\"
Cells(iFile, iPathColB).Value = PathParts(1) & "\"
Temp = Mid(sFile, Len(PathParts(0)) + Len(PathParts(1)) + 3)
Cells(iFile, iPathColC).Value = Left(Temp, Len(Temp) -
Len(PathParts(UBound(PathParts))))

NickHK

"dd" <dd.dd wrote in message
...
I have a file index, which inputs the paths in various columns for
Autofiltering and makes the files into hyperlinks. It takes a while to
process (22 rows takes approx 2 mins to process). There will be more files
added as work proceeds. I want to know if there is a way to speed up the
process, I've tried Application.Screenupdating = True/False, but it seems

to
take longer using this.
==
If oFolder.Files.Count 0 Then
For Each oFile In oFolder.Files
If oFile.Type = filetype Then

sFile = Mid(oFile.Path, 1)

'Start of first value iPos1 =
InStr(InStr(InStr(InStr(InStr(InStr(sFile, "\") + 1, sFile, "\") + 1,

sFile,
"\") + 1, sFile, "\") + 1, sFile, "\") + 1, sFile, "\")
'End of first value and start of second value
iPos2 = InStr(InStr(InStr(InStr(InStr(InStr(InStr(sFile, "\") + 1,
sFile, "\") + 1, sFile, "\") + 1, sFile, "\") + 1, sFile, "\") + 1, sFile,
"\") + 1, sFile, "\")
'End of second value and start of third value
iPos3 = InStr(InStr(InStr(InStr(InStr(InStr(InStr(InStr(sF ile, "\") +

1,
sFile, "\") + 1, sFile, "\") + 1, sFile, "\") + 1, sFile, "\") + 1, sFile,
"\") + 1, sFile, "\") + 1, sFile, "\")
'End of third value
iPos4 = InStrRev(sFile, "\")

'first string
Cells(iFile, iPathColA).Value = Mid(sFile, iPos1 + 1, iPos2 - iPos1)

Cells(iFile, iPathColB).Value = Mid(sFile, iPos2 + 1, iPos3 - iPos2)

Cells(iFile, iPathColC).Value = Mid(sFile, iPos3 + 1, iPos4 - iPos3)

Cells(iFile, iFileCol) = oFile.Name

' And a link in the Hyperlink column
Cells(iFile, iLinkCol).FormulaR1C1 = "=HYPERLINK(root &
RC[-4] & RC[-3]& RC[-2] & RC[-1] ,""HERE"")"

iFile = iFile + 1
End If
Next oFile
End If




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Advice to speed up process

Old news - suggested in response to a previous post. of course the spec
was a little bit different then.

Maybe he will like it better when you suggest it.

--
Regards,
Tom Ogilvy

"NickHK" wrote in message
...
Instead of using all those Instr's, use Split

Dim sFile As String
Dim PathParts() As String
Dim Temp As String

sFile = oFile.Path

PathParts = Split(sFile, "\")

Cells(iFile, iPathColA).Value = PathParts(0) & "\"
Cells(iFile, iPathColB).Value = PathParts(1) & "\"
Temp = Mid(sFile, Len(PathParts(0)) + Len(PathParts(1)) + 3)
Cells(iFile, iPathColC).Value = Left(Temp, Len(Temp) -
Len(PathParts(UBound(PathParts))))

NickHK

"dd" <dd.dd wrote in message
...
I have a file index, which inputs the paths in various columns for
Autofiltering and makes the files into hyperlinks. It takes a while to
process (22 rows takes approx 2 mins to process). There will be more
files
added as work proceeds. I want to know if there is a way to speed up the
process, I've tried Application.Screenupdating = True/False, but it seems

to
take longer using this.
==
If oFolder.Files.Count 0 Then
For Each oFile In oFolder.Files
If oFile.Type = filetype Then

sFile = Mid(oFile.Path, 1)

'Start of first value iPos1 =
InStr(InStr(InStr(InStr(InStr(InStr(sFile, "\") + 1, sFile, "\") + 1,

sFile,
"\") + 1, sFile, "\") + 1, sFile, "\") + 1, sFile, "\")
'End of first value and start of second value
iPos2 = InStr(InStr(InStr(InStr(InStr(InStr(InStr(sFile, "\") + 1,
sFile, "\") + 1, sFile, "\") + 1, sFile, "\") + 1, sFile, "\") + 1,
sFile,
"\") + 1, sFile, "\")
'End of second value and start of third value
iPos3 = InStr(InStr(InStr(InStr(InStr(InStr(InStr(InStr(sF ile, "\") +

1,
sFile, "\") + 1, sFile, "\") + 1, sFile, "\") + 1, sFile, "\") + 1,
sFile,
"\") + 1, sFile, "\") + 1, sFile, "\")
'End of third value
iPos4 = InStrRev(sFile, "\")

'first string
Cells(iFile, iPathColA).Value = Mid(sFile, iPos1 + 1, iPos2 - iPos1)

Cells(iFile, iPathColB).Value = Mid(sFile, iPos2 + 1, iPos3 - iPos2)

Cells(iFile, iPathColC).Value = Mid(sFile, iPos3 + 1, iPos4 - iPos3)

Cells(iFile, iFileCol) = oFile.Name

' And a link in the Hyperlink column
Cells(iFile, iLinkCol).FormulaR1C1 = "=HYPERLINK(root &
RC[-4] & RC[-3]& RC[-2] & RC[-1] ,""HERE"")"

iFile = iFile + 1
End If
Next oFile
End If








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Advice to speed up process

Tom,
I'm behind the times as usual <g.

NickHK

"Tom Ogilvy" wrote in message
...
Old news - suggested in response to a previous post. of course the spec
was a little bit different then.

Maybe he will like it better when you suggest it.

--
Regards,
Tom Ogilvy

"NickHK" wrote in message
...
Instead of using all those Instr's, use Split

Dim sFile As String
Dim PathParts() As String
Dim Temp As String

sFile = oFile.Path

PathParts = Split(sFile, "\")

Cells(iFile, iPathColA).Value = PathParts(0) & "\"
Cells(iFile, iPathColB).Value = PathParts(1) & "\"
Temp = Mid(sFile, Len(PathParts(0)) + Len(PathParts(1)) + 3)
Cells(iFile, iPathColC).Value = Left(Temp, Len(Temp) -
Len(PathParts(UBound(PathParts))))

NickHK

"dd" <dd.dd wrote in message
...
I have a file index, which inputs the paths in various columns for
Autofiltering and makes the files into hyperlinks. It takes a while to
process (22 rows takes approx 2 mins to process). There will be more
files
added as work proceeds. I want to know if there is a way to speed up

the
process, I've tried Application.Screenupdating = True/False, but it

seems
to
take longer using this.
==
If oFolder.Files.Count 0 Then
For Each oFile In oFolder.Files
If oFile.Type = filetype Then

sFile = Mid(oFile.Path, 1)

'Start of first value iPos1 =
InStr(InStr(InStr(InStr(InStr(InStr(sFile, "\") + 1, sFile, "\") + 1,

sFile,
"\") + 1, sFile, "\") + 1, sFile, "\") + 1, sFile, "\")
'End of first value and start of second value
iPos2 = InStr(InStr(InStr(InStr(InStr(InStr(InStr(sFile, "\") + 1,
sFile, "\") + 1, sFile, "\") + 1, sFile, "\") + 1, sFile, "\") + 1,
sFile,
"\") + 1, sFile, "\")
'End of second value and start of third value
iPos3 = InStr(InStr(InStr(InStr(InStr(InStr(InStr(InStr(sF ile, "\")

+
1,
sFile, "\") + 1, sFile, "\") + 1, sFile, "\") + 1, sFile, "\") + 1,
sFile,
"\") + 1, sFile, "\") + 1, sFile, "\")
'End of third value
iPos4 = InStrRev(sFile, "\")

'first string
Cells(iFile, iPathColA).Value = Mid(sFile, iPos1 + 1, iPos2 -

iPos1)

Cells(iFile, iPathColB).Value = Mid(sFile, iPos2 + 1, iPos3 -

iPos2)

Cells(iFile, iPathColC).Value = Mid(sFile, iPos3 + 1, iPos4 -

iPos3)

Cells(iFile, iFileCol) = oFile.Name

' And a link in the Hyperlink column
Cells(iFile, iLinkCol).FormulaR1C1 = "=HYPERLINK(root &
RC[-4] & RC[-3]& RC[-2] & RC[-1] ,""HERE"")"

iFile = iFile + 1
End If
Next oFile
End If








  #7   Report Post  
Posted to microsoft.public.excel.programming
dd dd is offline
external usenet poster
 
Posts: 95
Default Advice to speed up process

Tom,

I'm not as clever as you guys. I went for the MID() solution, as it was
already used in the code I had been given.
I had a go at incorporating the Split(s,"\") solution and have managed to
get the first two columns the way I want them. I've also included
application.Calculation = xlManual as advised. However, I don't notice that
much of a speed difference. Perhaps it's the network that is slowing things
down.

Regards
Dylan

PS Thanks to Tom and Nick HK for providing answers to this question.

"Tom Ogilvy" wrote in message
...
Old news - suggested in response to a previous post. of course the spec
was a little bit different then.

Maybe he will like it better when you suggest it.

--
Regards,
Tom Ogilvy

"NickHK" wrote in message
...
Instead of using all those Instr's, use Split

Dim sFile As String
Dim PathParts() As String
Dim Temp As String

sFile = oFile.Path

PathParts = Split(sFile, "\")

Cells(iFile, iPathColA).Value = PathParts(0) & "\"
Cells(iFile, iPathColB).Value = PathParts(1) & "\"
Temp = Mid(sFile, Len(PathParts(0)) + Len(PathParts(1)) + 3)
Cells(iFile, iPathColC).Value = Left(Temp, Len(Temp) -
Len(PathParts(UBound(PathParts))))

NickHK

"dd" <dd.dd wrote in message
...
I have a file index, which inputs the paths in various columns for
Autofiltering and makes the files into hyperlinks. It takes a while to
process (22 rows takes approx 2 mins to process). There will be more
files
added as work proceeds. I want to know if there is a way to speed up the
process, I've tried Application.Screenupdating = True/False, but it seems

to
take longer using this.
==
If oFolder.Files.Count 0 Then
For Each oFile In oFolder.Files
If oFile.Type = filetype Then

sFile = Mid(oFile.Path, 1)

'Start of first value iPos1 =
InStr(InStr(InStr(InStr(InStr(InStr(sFile, "\") + 1, sFile, "\") + 1,

sFile,
"\") + 1, sFile, "\") + 1, sFile, "\") + 1, sFile, "\")
'End of first value and start of second value
iPos2 = InStr(InStr(InStr(InStr(InStr(InStr(InStr(sFile, "\") + 1,
sFile, "\") + 1, sFile, "\") + 1, sFile, "\") + 1, sFile, "\") + 1,
sFile,
"\") + 1, sFile, "\")
'End of second value and start of third value
iPos3 = InStr(InStr(InStr(InStr(InStr(InStr(InStr(InStr(sF ile, "\") +

1,
sFile, "\") + 1, sFile, "\") + 1, sFile, "\") + 1, sFile, "\") + 1,
sFile,
"\") + 1, sFile, "\") + 1, sFile, "\")
'End of third value
iPos4 = InStrRev(sFile, "\")

'first string
Cells(iFile, iPathColA).Value = Mid(sFile, iPos1 + 1, iPos2 - iPos1)

Cells(iFile, iPathColB).Value = Mid(sFile, iPos2 + 1, iPos3 - iPos2)

Cells(iFile, iPathColC).Value = Mid(sFile, iPos3 + 1, iPos4 - iPos3)

Cells(iFile, iFileCol) = oFile.Name

' And a link in the Hyperlink column
Cells(iFile, iLinkCol).FormulaR1C1 = "=HYPERLINK(root &
RC[-4] & RC[-3]& RC[-2] & RC[-1] ,""HERE"")"

iFile = iFile + 1
End If
Next oFile
End If







  #8   Report Post  
Posted to microsoft.public.excel.programming
dd dd is offline
external usenet poster
 
Posts: 95
Default Request advice on Split(sFile, "\")

Nick

I wonder if you can help me with the data in Column C

With the following snippet of code, I want the ..iPathColC).Value to equal
the path string between PathParts(8) and the filename:

That is, for the path:
P:\GB123\Rail\Jobs\Feb06\Surveys\Trial surveys\Kyle of
Lochalsh\Station\Proforma\Part01\Station 01.pfm, I want to extract \Proforma
and any other directories before the filename into the ... iPAthColC).Value


sFile = oFile.Path

PathParts = Split(sFile, "\")

Cells(iFile, iPathColA).Value = PathParts(6) & "\"
Cells(iFile, iPathColB).Value = PathParts(7) & "\"

Temp = Mid(sFile, Len(PathParts(6)) + Len(PathParts(7)))
Cells(iFile, iPathColC).Value = Left(Temp, Len(Temp) -
Len(PathParts(UBound(PathParts))))

Cells(iFile, iFileCol) = oFile.Name

Regards
D Dawson


  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Request advice on Split(sFile, "\")

As you seems to have many requirements, it would be better to make a
function to get the parts, instead of repeating split/combine code.
Something like this below. Note you should add error handling:

Public Function GetPathParts(FullPath As String, _
ByVal StartPart As Long, _
ByVal EndPart As Long) _
As String

Dim i As Long
Dim PathParts() As String
Dim TempStr As String

PathParts = Split(FullPath, "\")

If StartPart < 0 Then
StartPart = UBound(PathParts) + StartPart
ElseIf StartPart 0 Then
StartPart = StartPart - 1
Else
GetPathParts = "Invalid StartPart"
Exit Function
End If

If EndPart < 0 Then
EndPart = UBound(PathParts) + EndPart
ElseIf EndPart 0 Then
EndPart = EndPart - 1
Else
EndPart = UBound(PathParts)
End If

For i = StartPart To EndPart
TempStr = TempStr & PathParts(i) & "\"
Next
If InStr(1, PathParts(EndPart), ".") 0 Then TempStr = Left(TempStr,
Len(TempStr) - 1)

GetPathParts = TempStr

End Function

Note that a -ve StartPart/EndPart counts from the right, whilst zero goes to
the end. A little testing produced these results:

P:\GB123\Rail\Jobs\Feb06\Surveys\Trial surveys\Kyle of
Lochalsh\Station\Proforma\Part01\Station 01.pfm

Start End Returned
1 1 P:\
1 2 P:\GB123\
8 -1 Kyle of Lochalsh\Station\Proforma\Part01\
8 -2 Kyle of Lochalsh\Station\Proforma\
3 5 Rail\Jobs\Feb06\
3 0 Rail\Jobs\Feb06\Surveys\Trial surveys\Kyle of
Lochalsh\Station\Proforma\Part01\Station 01.pfm
1 0 P:\GB123\Rail\Jobs\Feb06\Surveys\Trial surveys\Kyle of
Lochalsh\Station\Proforma\Part01\Station 01.pfm
-3 -1 Station\Proforma\Part01\

NickHK

"dd" <dd.dd wrote in message ...
Nick

I wonder if you can help me with the data in Column C

With the following snippet of code, I want the ..iPathColC).Value to equal
the path string between PathParts(8) and the filename:

That is, for the path:
P:\GB123\Rail\Jobs\Feb06\Surveys\Trial surveys\Kyle of
Lochalsh\Station\Proforma\Part01\Station 01.pfm, I want to extract

\Proforma
and any other directories before the filename into the ...

iPAthColC).Value


sFile = oFile.Path

PathParts = Split(sFile, "\")

Cells(iFile, iPathColA).Value = PathParts(6) & "\"
Cells(iFile, iPathColB).Value = PathParts(7) & "\"

Temp = Mid(sFile, Len(PathParts(6)) + Len(PathParts(7)))
Cells(iFile, iPathColC).Value = Left(Temp, Len(Temp) -
Len(PathParts(UBound(PathParts))))

Cells(iFile, iFileCol) = oFile.Name

Regards
D Dawson




  #10   Report Post  
Posted to microsoft.public.excel.programming
dd dd is offline
external usenet poster
 
Posts: 95
Default Request advice on Split(sFile, "\")

NickHK

Thank you very much for your help with this.
The code you gave me works perfectly and your instructions were very
helpful.

Dylan Dawson
Scotland

"NickHK" wrote in message
...
As you seems to have many requirements, it would be better to make a
function to get the parts, instead of repeating split/combine code.
Something like this below. Note you should add error handling:

Public Function GetPathParts(FullPath As String, _
ByVal StartPart As Long, _
ByVal EndPart As Long) _
As String

Dim i As Long
Dim PathParts() As String
Dim TempStr As String

PathParts = Split(FullPath, "\")

If StartPart < 0 Then
StartPart = UBound(PathParts) + StartPart
ElseIf StartPart 0 Then
StartPart = StartPart - 1
Else
GetPathParts = "Invalid StartPart"
Exit Function
End If

If EndPart < 0 Then
EndPart = UBound(PathParts) + EndPart
ElseIf EndPart 0 Then
EndPart = EndPart - 1
Else
EndPart = UBound(PathParts)
End If

For i = StartPart To EndPart
TempStr = TempStr & PathParts(i) & "\"
Next
If InStr(1, PathParts(EndPart), ".") 0 Then TempStr = Left(TempStr,
Len(TempStr) - 1)

GetPathParts = TempStr

End Function

Note that a -ve StartPart/EndPart counts from the right, whilst zero goes to
the end. A little testing produced these results:

P:\GB123\Rail\Jobs\Feb06\Surveys\Trial surveys\Kyle of
Lochalsh\Station\Proforma\Part01\Station 01.pfm

Start End Returned
1 1 P:\
1 2 P:\GB123\
8 -1 Kyle of Lochalsh\Station\Proforma\Part01\
8 -2 Kyle of Lochalsh\Station\Proforma\
3 5 Rail\Jobs\Feb06\
3 0 Rail\Jobs\Feb06\Surveys\Trial surveys\Kyle of
Lochalsh\Station\Proforma\Part01\Station 01.pfm
1 0 P:\GB123\Rail\Jobs\Feb06\Surveys\Trial surveys\Kyle of
Lochalsh\Station\Proforma\Part01\Station 01.pfm
-3 -1 Station\Proforma\Part01\

NickHK

"dd" <dd.dd wrote in message ...
Nick

I wonder if you can help me with the data in Column C

With the following snippet of code, I want the ..iPathColC).Value to equal
the path string between PathParts(8) and the filename:

That is, for the path:
P:\GB123\Rail\Jobs\Feb06\Surveys\Trial surveys\Kyle of
Lochalsh\Station\Proforma\Part01\Station 01.pfm, I want to extract

\Proforma
and any other directories before the filename into the ...

iPAthColC).Value


sFile = oFile.Path

PathParts = Split(sFile, "\")

Cells(iFile, iPathColA).Value = PathParts(6) & "\"
Cells(iFile, iPathColB).Value = PathParts(7) & "\"

Temp = Mid(sFile, Len(PathParts(6)) + Len(PathParts(7)))
Cells(iFile, iPathColC).Value = Left(Temp, Len(Temp) -
Len(PathParts(UBound(PathParts))))

Cells(iFile, iFileCol) = oFile.Name

Regards
D Dawson





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
Speed up Program Process maperalia Excel Programming 3 January 26th 06 07:54 PM
Speed up the process Ali Baba Charts and Charting in Excel 2 October 3rd 05 06:40 PM
How to count process running time ( process not finished) miao jie Excel Programming 0 January 13th 05 09:23 AM
How to count process running time ( process not finished) miao jie Excel Programming 2 January 12th 05 06:01 AM
Question to speed up a process - Patrick[_5_] Excel Programming 0 April 6th 04 04:17 PM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"