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:

Some videos you may like

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().

taigovinda

Well-known Member
Joined
Mar 28, 2007
Messages
2,639
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
 

Watch MrExcel Video

Forum statistics

Threads
1,128,025
Messages
5,628,196
Members
416,299
Latest member
Kxs00301

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
Top