Cell Value = date in this month

mskeys2xx3

New Member
Joined
Dec 1, 2009
Messages
7
Hi,

Is there a way for me to check if a cells value is within this month in VBA?
I have a spreadsheet where row I has dates. I want to find all of the cells that have a date that occurs this month.

ie- I2 = 10/29/2009, I3 = 12/13/09, I4 = 12/29/09
I want to pullout rows 3 and 4 because they occur this month (december).

I know how to cycle through and check all the rows and how to pull them out. I just dont kow if there is a way for me to see if the date occurs this month.
 
Last edited:

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Try this:

Rich (BB code):
Option Explicit
Sub test()
Dim rngCell As Range
For Each rngCell In Range("I2:I4")
    If Month(rngCell) = Month(Date) And Year(rngCell) = Year(Date) Then
        MsgBox rngCell.Address & " is in " & Format(Date, "mmmm yyyy")
    End If
Next
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,829
Messages
6,121,826
Members
449,051
Latest member
excelquestion515

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top