View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Smallweed Smallweed is offline
external usenet poster
 
Posts: 133
Default Find a cell based on current month

Sub FindMonth()
Dim rng As Range
Dim intMnth As Integer
Range("E1").EntireColumn.SpecialCells(xlCellTypeCo nstants, 23).Select
intMnth = Month(Date)
Do Until intMnth = 0
For Each rng In Selection
If Month(rng.Value) = intMnth Then
rng.Select
Exit Do
End If
Next
intMnth = intMnth - 1
Loop
If intMnth = 0 Then MsgBox "Cannot find month before current month this
year"
End Sub


"mathel" wrote:

In Column E in a workbook I have cells with a month in it, formatted 'mmm'.
There will not be a cell for every month of the year. For example, one cell
could be Jan, the other May, Aug, etc.

Using VBA, is it possible to look for the current month in the column, if it
doesn't exist, look for the previous month until it finds the most recent.
IE: Look for Nov, if Nov doesn't exist, find Oct, if Oct not found, look for
Sep?

Thanks for any help
--
Linda