Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Looking for a Month Name in a String
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" |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Looking for a Month Name in a String
This could work, I wasn't sure what order you have your data in your cells so
I'm presuming they're all just down on colum, but you can change to suit your needs. I'm sure there will be a better way, but this should work (not had chance to test it) Option Explicit Public Sub loopAndFindMonths() size = Sheets("SheetName").Cells(Rows.Count, "A").Row Dim i As Long For i = 1 To size splitUpString Sheets("SheetName").Cells(i, 1).Value, i Next i End Sub Private Sub splitUpString(str As String, rowAt As Long) Dim splitString() As String splitString = split(str, " ") Dim i As Integer For i = 0 To UBound(splitString) If CheckIsMonth(Mid(splitString(i), 1, 3)) Then Sheets("SheetName").Cells(rowAt, 2).Value = Mid(splitString(i), 1, 3) End If Next i End Sub Private Function CheckIsMonth(str As String) As Boolean str = UCase(str) Select Case str Case "JAN" CheckIsMonth = True Case "FEB" CheckIsMonth = True Case "MAR" CheckIsMonth = True Case Else CheckIsMonth = False End Select End Function |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Extract Month From A Text String | Excel Discussion (Misc queries) | |||
Looking for a Month Name in a String | Excel Programming | |||
Convert month number to string | Excel Worksheet Functions | |||
copy worksheet from previous month and rename to current month | Excel Programming | |||
Lookup the month in a date string 01/03/05 | Excel Worksheet Functions |