LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default Choping Up a String

On 27 Mar 2007 09:25:38 -0700, "Pam" wrote:

Hi

I was wondering if anyone new exactly how to use the chop function
to chop up a string. Basically what I am trying to do is chop up thre
namer of
a file which contains the filename with date. I want to get the date
for that file
name; Here is an example

MY Sheet_070327_US.xls

I want to chop it up so I just end up with the date.



Your help is appreicated. Thanking you in advance


Pam


Here's another way to extract the date string. It depends on the string being
six digits in length and followed by an underscore.

The string is stored at colMatches(0) as a string, and can be used however.

==============================
Option Explicit

Sub GetDate()
Const str As String = "MY Sheet_070327_US.xls"
Const sPattern As String = "\d{6}(?=_)"

Dim objRegExp As Object
Dim colMatches As Object

Set objRegExp = CreateObject("VBScript.RegExp")
With objRegExp
.Pattern = sPattern
.IgnoreCase = True
.Global = True

If .Test(str) = True Then
Set colMatches = .Execute(str)
Debug.Print colMatches(0)
End If
End With

End Sub
==============================
--ron
 
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
Change 3 letter text string to a number string Pete Excel Discussion (Misc queries) 3 December 31st 07 07:47 PM
Replace Hyperlink Addresses Help 'Dim OldStr As String, NewStr As String Ron[_14_] Excel Programming 6 January 23rd 07 07:38 PM
Importing Long String - String Manipulation (INVRPT) (EDI EANCOM 96a) Brian Excel Programming 3 February 9th 06 03:38 PM
Importing Long String - String Manipulation (EDI EANCOM 96a) Brian Excel Programming 6 February 9th 06 12:27 PM
to search for a string and affect data if it finds the string? Shwaman Excel Worksheet Functions 1 January 11th 06 12:56 AM


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