Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 208
Default Extracting specific data from a string

I have several reports that are named using a specific naming protocol:

Center "C&A PF" Month Year Week Analyst Initials

Here a few examples:

Greensboro C&A PF Jan 09 wk2 lw
Heathrow C&A PF Mar 09 wk3 et
London C&A PF Feb 09 wk5 bm

I need to extract the month from the file name and assign it to a variable,
say Mnth. So for the Greensboro report Mnth = Jan. For the London report
Mnth = Feb, etc. How can I do this?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Extracting specific data from a string

Use Split:

Sub MonthGetter()
Dim s As String
s = "Greensboro C&A PF Jan 09 wk2 lw"
v = Split(s, " ")
MsgBox (v(3))
End Sub

Split in VBA is similar to Text to Columns in the worksheet.
--
Gary''s Student - gsnu200855


"Bishop" wrote:

I have several reports that are named using a specific naming protocol:

Center "C&A PF" Month Year Week Analyst Initials

Here a few examples:

Greensboro C&A PF Jan 09 wk2 lw
Heathrow C&A PF Mar 09 wk3 et
London C&A PF Feb 09 wk5 bm

I need to extract the month from the file name and assign it to a variable,
say Mnth. So for the Greensboro report Mnth = Jan. For the London report
Mnth = Feb, etc. How can I do this?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Extracting specific data from a string

Suppose..

strReport = "Greensboro C&A PF Jan 09 wk2 lw"
strMonth = Split(strReport)(3)

If this post helps click Yes
---------------
Jacob Skaria


"Bishop" wrote:

I have several reports that are named using a specific naming protocol:

Center "C&A PF" Month Year Week Analyst Initials

Here a few examples:

Greensboro C&A PF Jan 09 wk2 lw
Heathrow C&A PF Mar 09 wk3 et
London C&A PF Feb 09 wk5 bm

I need to extract the month from the file name and assign it to a variable,
say Mnth. So for the Greensboro report Mnth = Jan. For the London report
Mnth = Feb, etc. How can I do this?

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
Extracting Specific Numbers in a String of Text cardan Excel Programming 2 November 15th 08 01:28 AM
Extracting Data out of a string ranswrt Excel Programming 9 August 1st 08 03:16 PM
extracting data from a string Iguss Excel Worksheet Functions 4 November 19th 07 09:50 PM
Formula for extracting data from a string LFM Excel Worksheet Functions 10 April 12th 07 03:59 AM
I need help -extracting specific data Karlos[_2_] Excel Programming 0 November 8th 05 02:47 PM


All times are GMT +1. The time now is 08:54 AM.

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"