Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Testing for Month in a cell using VBA
The following vb code is my starting point. I need to test for the Month then
the day. Col A is a date( a2 to a365). What do I do to this code to accomplish my gola? CurDte = Date SubStr = Month(CurDte) Set MyCell = ActiveSheet.Range("A2") If MyCell.Value < SubStr Then Set MyCell = MyCell.Offset(1, 0) ElseIf MyCell.Value.Month = SubStr Then Exit Do End If |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Testing for Month in a cell using VBA
This is just demo stuff:
Sub rick() CurDte = Date SubStr = Month(CurDte) Set MyCell = ActiveSheet.Range("A2") v = DateValue(MyCell.Value) vm = Month(v) If vm < SubStr Then Set MyCell = MyCell.Offset(1, 0) ElseIf vm = SubStr Then End If End Sub Note we get v as the worksheet value then calculate the month number as vm we could get the day as vd=Day(v) Use these variables in your if/else/then logic -- Gary''s Student - gsnu200720 "Rick" wrote: The following vb code is my starting point. I need to test for the Month then the day. Col A is a date( a2 to a365). What do I do to this code to accomplish my gola? CurDte = Date SubStr = Month(CurDte) Set MyCell = ActiveSheet.Range("A2") If MyCell.Value < SubStr Then Set MyCell = MyCell.Offset(1, 0) ElseIf MyCell.Value.Month = SubStr Then Exit Do End If |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
testing for a value in a cell | Excel Discussion (Misc queries) | |||
transfer cell $ amount to other sheet month-to-month without overc | Excel Discussion (Misc queries) | |||
Testing a cell | Excel Programming | |||
testing cell value | Excel Programming | |||
testing the value of a cell | Excel Programming |