Month Name issue

rfletcher35

Active Member
Joined
Jul 20, 2011
Messages
300
Office Version
  1. 365
Platform
  1. Windows
I am currently using a autofilter in my vba code to select a day range. I need to change this code to select current month

However even if I change the cell format to MMMM it doesn't register the word i.e. "December" in this case so I can filter on it.
As you can see below I am using CurMonth as my range
In Cell C2 I have the word December as formatted as date using custom MMMM

Dim rng365 As Range
Dim CurMonth As Range


Sheets("Results Sheet").Select
Range("P5:BL3000").Select
Selection.ClearContents

' 365 - 1 Year of Work No Absence
Set CurMonth = Range("C2")
With Sheets("MPR Data")
'.Range("$T$4:$AD$4000").AutoFilter Field:=1, Criteria1:="=365", Operator:=xlFilterValues
.Range("$T$4:$AE$4000").AutoFilter Field:=12, Criteria1:=CurMonth.Value, Operator:=xlFilterValues
On Error Resume Next
Set rng365 = .Range("T5:AE4000").SpecialCells(xlCellTypeVisible)
On Error GoTo 0
End With

Can anyone help with this please?

Thanks

Fletch
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Fletch

Changing the format doesn't change the value, so Excel will still see the full date.

In the data what do you have, the full date formatted to show month or the month as text?
 
Upvote 0
Hi,

Thanks for the reply I've sorted it using =TEXT command in excel now.

Thanks
 
Upvote 0

Forum statistics

Threads
1,213,536
Messages
6,114,208
Members
448,554
Latest member
Gleisner2

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