Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 320
Default Truncat the file name in long directory using macro

Try:

Sub GetFileUntestedCode()
For i=1 to 3
with Sheets(i)
for each x in .range("B1:B" & .range(B65536").end(xlup).row) 'note the
leading "." before Range
x.value=dir(x.value)
Next
End With
Next
End Sub

If you have a valid path in a string, then Dir(thatString) will return the
last piece.

Bob Umlas
Excel MVP


"Lillian" wrote in message
...
I have one excel spreed sheet, it have three worksheet,
they are sheet1, sheet2, sheet3, in each worksheets on
the column B each row has real long file directory,
example:
J:\files\docfiles\amaya01\demand.mcp.wpd, all I need is
last file name: demand.mcp.wpd, it means I only need
the file name after the last slash "\", all the column B
has different rows of file name another example:
j:\FILES\DOCFILES\Civil Service\CS-SUBIA\OLGA.SRP, all
I need is OLGA.SRP file name, so can we write the macro
removed everything before last slash "\".

SO this macro has be in the loop for
sheet1,sheet2,sheet3.

thanks for the help.

Lillian



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 47
Default Truncat the file name in long directory using macro

Bob:

I can not run this macro, i and x did not define as
long for something, also do you take care of last
slash "\" in this macro.

thanks.

Lillian
-----Original Message-----
Try:

Sub GetFileUntestedCode()
For i=1 to 3
with Sheets(i)
for each x in .range("B1:B" & .range(B65536").end

(xlup).row) 'note the
leading "." before Range
x.value=dir(x.value)
Next
End With
Next
End Sub

If you have a valid path in a string, then Dir

(thatString) will return the
last piece.

Bob Umlas
Excel MVP


"Lillian" wrote in

message
...
I have one excel spreed sheet, it have three worksheet,
they are sheet1, sheet2, sheet3, in each worksheets on
the column B each row has real long file directory,
example:
J:\files\docfiles\amaya01\demand.mcp.wpd, all I need is
last file name: demand.mcp.wpd, it means I only need
the file name after the last slash "\", all the column

B
has different rows of file name another example:
j:\FILES\DOCFILES\Civil Service\CS-SUBIA\OLGA.SRP, all
I need is OLGA.SRP file name, so can we write the macro
removed everything before last slash "\".

SO this macro has be in the loop for
sheet1,sheet2,sheet3.

thanks for the help.

Lillian



.

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
http://CannotDeleteFile.net - Cannot Delete File? Try Long Path ToolFilename is too long? Computer Complaining Your Filename Is Too Long? TheLong Path Tool Can Help While most people can go about their businessblissfully unaware of the Windo Max Loger Excel Discussion (Misc queries) 0 June 14th 11 04:30 PM
Takes too long for Filedialog to change directory File selection in office2003 Excel Discussion (Misc queries) 1 May 1st 06 05:33 AM
Excel should let me sort the file directory when saving a file Beanee70 Excel Discussion (Misc queries) 0 March 14th 06 07:03 AM
Saving files in the same network directory takes too long time!! tev Setting up and Configuration of Excel 2 March 9th 05 09:05 PM
How do I force an Excel macro to ask me which file and directory? Ramius Excel Discussion (Misc queries) 4 January 14th 05 03:26 PM


All times are GMT +1. The time now is 11:30 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"