View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Remove .xls from selected files

globalbook.Worksheets("X").Cells(r, 1).Value =
Left(insertbook.Name,len(insertBook.Name)-4)

or

globalbook.Worksheets("X").Cells(r, 1).Value
=Application.Substitute(insertBook.Name,".xls","")

or use the VBA replace function in xl2000 and later instead of
Application.Substitute.

--
Regards,
Tom Ogilvy

"Zurn" wrote in message
...

With the code below I get a range of cells from different files and put
it in a new file named globalbook

FName = Application.GetOpenFilename(filefilter:="Excel Files (*.xls),
*.xls", _
MultiSelect:=True)
..
For... ...
..
globalbook.Worksheets("X").Cells(r, 1).Value = insertbook.Name
r+1
..


The last line writes the name of each file on sheet X

My problem is that I don't need the *.xls * to be written on sheet
X...*how can I easily trim the .xls from the filename?*


--
Zurn
------------------------------------------------------------------------
Zurn's Profile:

http://www.excelforum.com/member.php...o&userid=14645
View this thread: http://www.excelforum.com/showthread...hreadid=263149