Home |
Search |
Today's Posts |
#9
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Change 3 letter text string to a number string | Excel Discussion (Misc queries) | |||
Replace Hyperlink Addresses Help 'Dim OldStr As String, NewStr As String | Excel Programming | |||
Importing Long String - String Manipulation (INVRPT) (EDI EANCOM 96a) | Excel Programming | |||
Importing Long String - String Manipulation (EDI EANCOM 96a) | Excel Programming | |||
to search for a string and affect data if it finds the string? | Excel Worksheet Functions |