Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 260
Default Trim "\" Value

Hey guys I have the following value of a variable:

Q:\CS Management Reports\Reports Setup\Administrator
Files\Exported Modules\test.bas

I would like to trim that value to where it only gives me
the value "test.bas"

How do I do this?


Thanx
Todd Huttenstine
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default Trim "\" Value

Try something like

Function GetName(FullPath As String) As String
Dim FileName As Variant
FileName = Split(FullPath, Application.PathSeparator)
FileName = FileName(UBound(FileName))
GetName = FileName
End Function

--
Regards,

Juan Pablo González

"Todd Huttenstine" wrote in message
...
Hey guys I have the following value of a variable:

Q:\CS Management Reports\Reports Setup\Administrator
Files\Exported Modules\test.bas

I would like to trim that value to where it only gives me
the value "test.bas"

How do I do this?


Thanx
Todd Huttenstine



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 88
Default Trim "\" Value

Hi Todd,

Todd Huttenstine schrieb:
Hey guys I have the following value of a variable:

Q:\CS Management Reports\Reports Setup\Administrator
Files\Exported Modules\test.bas

I would like to trim that value to where it only gives me
the value "test.bas"

How do I do this?


since Excel2000 you can use the Split Function:

Dim strText As String
Dim varSplit As Variant

strText = "Q:\CS Management Reports\Reports Setup\AdministratorFiles\Exported Modules\test.bas"
varSplit = VBA.Split(strText, "\")
strText = varSplit(UBound(varSplit))

--
Mit freundlichen Grüssen

Melanie Breden
- Microsoft MVP für Excel -

http://excel.codebooks.de (Das Excel-VBA Codebook)

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default Trim "\" Value

Public Function fileNameOnly(fPth As String) As String
Dim i As Integer, length As Integer, Temp As String

length = Len(fPth)
Temp = ""
For i = length To 1 Step -1
If Mid(fPth, i, 1) = Application.PathSeparator Then
fileNameOnly = Temp
Exit Function
End If
Temp = Mid(fPth, i, 1) & Temp
Next i
fileNameOnly = fPth
End Function
-----Original Message-----
Hey guys I have the following value of a variable:

Q:\CS Management Reports\Reports Setup\Administrator
Files\Exported Modules\test.bas

I would like to trim that value to where it only gives me
the value "test.bas"

How do I do this?


Thanx
Todd Huttenstine
.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Trim "\" Value

strVar = "Q:\CS Management Reports\Reports Setup\Administrator
Files\Exported Modules\test.bas"
strLen = Len(strVar)
slashLoc = InStrRev(strVar, "\")
fileNameLen = strLen - slashLoc
fileName = Right(strVar, fileNameLen)

This works in theory, but I haven't tested it so let me know if it doe
not work. - Piku

--
Message posted from http://www.ExcelForum.com



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default Trim "\" Value

The code samples that used Split (or VBA.Split) will work for xl2k or higher.
The other code is should work in all versions. (I didn't test, though.)

Split was added in xl2k.



Todd Huttenstine wrote:

Hey guys I have the following value of a variable:

Q:\CS Management Reports\Reports Setup\Administrator
Files\Exported Modules\test.bas

I would like to trim that value to where it only gives me
the value "test.bas"

How do I do this?

Thanx
Todd Huttenstine


--

Dave Peterson

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 107
Default Trim "\" Value

Dave Peterson wrote:
The code samples that used Split (or VBA.Split) will work for xl2k or higher.
The other code is should work in all versions. (I didn't test, though.)

Split was added in xl2k.


And I think the same restriction applies to the InStrRev sample

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Trim "\" Value

absolutely.

--
Regards,
Tom Ogilvy

"Steve Garman" wrote in message
...
Dave Peterson wrote:
The code samples that used Split (or VBA.Split) will work for xl2k or

higher.
The other code is should work in all versions. (I didn't test, though.)

Split was added in xl2k.


And I think the same restriction applies to the InStrRev sample



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
=TRIM(LEFT(B47,FIND(" ",B47)-1)) Jim Excel Discussion (Misc queries) 4 January 28th 10 08:45 PM
=TRIM(LEFT(B50,FIND(" ",B50)-1)) Jim Excel Discussion (Misc queries) 4 January 14th 10 10:56 PM
=SUMPRODUCT(--(TRIM(A1:A10)<"")), what does the "--" mean? Ray Excel Worksheet Functions 2 August 28th 08 08:05 AM
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
Count occurences of "1"/"0" (or"TRUE"/"FALSE") in a row w. conditions in the next BCB New Users to Excel 7 May 13th 06 10:02 PM


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