Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Remove .xls from selected files


With the code below I get a range of cells from different files and pu
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 shee
X...*how can I easily trim the .xls from the filename?

--
Zur
-----------------------------------------------------------------------
Zurn's Profile: http://www.excelforum.com/member.php...fo&userid=1464
View this thread: http://www.excelforum.com/showthread.php?threadid=26314

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Remove .xls from selected files

Zurn,

Replace

insertbook.Name

with

Replace(insertbook.Name,".xls,"")

HTH,
Bernie
MS Excel MVP

"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



  #3   Report Post  
Posted to microsoft.public.excel.programming
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



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Remove .xls from selected files

typo:

Replace(insertbook.Name,".xls,"")

should be


Replace(insertbook.Name,".xls","")

Note that the replace command was added in xl2000.

--
Regards,
Tom Ogilvy

"Bernie Deitrick" <deitbe @ consumer dot org wrote in message
...
Zurn,

Replace

insertbook.Name

with

Replace(insertbook.Name,".xls,"")

HTH,
Bernie
MS Excel MVP

"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





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
Remove Last x Character(s) in Selected Cells rojobrown Excel Worksheet Functions 6 April 1st 10 06:52 AM
Remove selected data from a list kingie Excel Discussion (Misc queries) 3 March 25th 10 11:32 AM
How to open files in order they were selected Kevin Excel Discussion (Misc queries) 0 July 20th 07 02:54 PM
Need to remove selected characters Natedanger Excel Discussion (Misc queries) 2 September 17th 05 02:35 PM
Remove rows based on any selected criteria Juan[_2_] Excel Programming 0 September 25th 03 06:13 PM


All times are GMT +1. The time now is 04:44 PM.

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"