Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Separating workbook name from extension

Hi guys,

Can anyone please let me know whether any code exists which separates a
workbook name from its extension (e.g. a spreadsheet named "test.xls" would
be separated into "test" and ".xls")?

Thanks in advance,
Will
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 79
Default Separating workbook name from extension

filename = "test.xls"
newName = Left(filename, len(filename) - 4) & vbTab & Right(filename, 4)

"William Francis" wrote in
message ...
Hi guys,

Can anyone please let me know whether any code exists which separates a
workbook name from its extension (e.g. a spreadsheet named "test.xls"

would
be separated into "test" and ".xls")?

Thanks in advance,
Will



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Separating workbook name from extension

VBA or worksheet function .

Worksheet function, with only one embedded dot
=LEFT(A2,FIND(".",A2)-1) and
=MID(A2,FIND(".",A2)+1,32)

or if there can be multiple dots
=LEFT(A1,FIND("~",SUBSTITUTE(A1,".","~",LEN(A1)-LEN(SUBSTITUTE(A1,".",""))))
-1)
=MID(A1,FIND("~",SUBSTITUTE(A1,".","~",LEN(A1)-LEN(SUBSTITUTE(A1,".",""))))+
1,32)

with VBA


Function SplitName(InVal As Range, ext As Boolean)
Dim ipos As Long
Dim sText As String

If TypeName(InVal) = "Range" Then
sText = InVal.Value
Else
sText = InVal
End If
For ipos = Len(sText) To 1 Step -1
If Mid(InVal.Value, ipos, 1) = "." Then
Exit For
End If
Next ipos

If ext Then
SplitName = Mid(sText, ipos + 1, 32)
Else
SplitName = Left(sText, ipos - 1)
End If
End Function


Pass the text or the text cell, and indicate whether you want the file
extension or not.


pass

--

HTH

RP
(remove nothere from the email address if mailing direct)


"William Francis" wrote in
message ...
Hi guys,

Can anyone please let me know whether any code exists which separates a
workbook name from its extension (e.g. a spreadsheet named "test.xls"

would
be separated into "test" and ".xls")?

Thanks in advance,
Will



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
copy formula from 1 workbook to another & not carry the extension bpittman Excel Worksheet Functions 3 November 12th 07 03:23 PM
Separating 1 workbook into multiple workbooks Aleisha Mollen Excel Discussion (Misc queries) 9 August 28th 07 11:07 PM
Separating a List onto multiple worksheets in the same workbook based off 1 criteria DMRbaxter Excel Worksheet Functions 6 April 19th 07 01:36 PM
Transformation d'images avec une extension .jpg ou .jpeg en images avec extension .bmp ou .ico imej-clavier Excel Discussion (Misc queries) 1 May 28th 05 05:52 PM
Separating one large workbook into several smaller workbooks MaryB@FIC Excel Programming 2 October 12th 04 09:07 PM


All times are GMT +1. The time now is 03:50 PM.

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"