Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 334
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default 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
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
testing for a value in a cell Dave Eade Excel Discussion (Misc queries) 1 February 11th 10 11:54 AM
transfer cell $ amount to other sheet month-to-month without overc Colin2u Excel Discussion (Misc queries) 1 July 28th 05 02:36 AM
Testing a cell Michael Singmin Excel Programming 5 November 29th 03 05:56 AM
testing cell value Thompson, Joseph Excel Programming 1 November 8th 03 09:41 AM
testing the value of a cell Zeraia Excel Programming 3 October 22nd 03 12:58 AM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"