Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 947
Default Looking for a Month Name in a String

Not any better, but another variation along this theme...

Mths = Application.GetCustomListContents(3)

For Each myCell In myRng.Cells
For Mth = 1 To 12
If InStr(1, myCell.Value, Mths(Mth), vbTextCompare) 0 Then
'etc...

--
Dana DeLouis



"Dave Peterson" wrote in message
...
You can loop through all the cells with something like:

Option Explicit
Sub testme()

Dim myRng As Range
Dim wks As Worksheet
Dim mCtr As Long
Dim myCell As Range
Dim myStr As String

Set wks = Worksheets("Sheet1")
Set myRng = Nothing
On Error Resume Next
Set myRng = wks.Cells.SpecialCells(xlCellTypeConstants, xlTextValues)
On Error GoTo 0

If myRng Is Nothing Then
MsgBox "No text cells found!"
Exit Sub
End If

For Each myCell In myRng.Cells
For mCtr = 1 To 12
myStr = Format(DateSerial(2008, mCtr, 1), "mmm")
'xl2002(?) or higher
myStr = MonthName(Month:=mCtr, abbreviate:=True)
If InStr(1, myCell.Value, myStr, vbTextCompare) 0 Then
'do what
MsgBox "Found one: " & myCell.Address & "--" & myStr
'stop looking in that cell?
Exit For
End If
Next mCtr
Next myCell

End Sub

=======
But looping through the cells isn't always the quickest way to get things
done.
I don't know what you're doing, but you may want to consider using
Find/FindNext
to search for the month abbreviations.



wutzke wrote:

Within my worksheet is a number of cells that MIGHT contain a name of
a Month

white mothistled January holdew February tracour December necters
exally slopers
tracing sentagen March samputs twistwased June unent chama puls
moperveyeberannochas micracadwatextilitiously
hung flamons cons bradritabol cashortimizes red

Is there a way programmically to loop thru each cell and search for
"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct",
"Nov", Dec"


--

Dave Peterson



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
Extract Month From A Text String George Excel Discussion (Misc queries) 4 May 12th 10 01:18 AM
excel to make the days cary over month to month automaticly GARY New Users to Excel 1 April 19th 08 06:05 PM
Convert month number to string Graham Excel Worksheet Functions 6 November 16th 06 07:46 PM
copy worksheet from previous month and rename to current month Dan E. Excel Programming 4 December 8th 05 09:40 PM
Lookup the month in a date string 01/03/05 Una Excel Worksheet Functions 1 March 30th 05 09:45 AM


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