# How to hide a cell if the date is equal to the 1st of the month

#### Hmerman

##### Board Regular
Hello all,

I am trying to tell a cell to hide if the date in the cell is equal to the first of the month.

I am struggling with the code to check if the cell is equal to the first of the month.

Here is my
Code:
``````If DateValue(Date("yyyy/mm/01")) = DateValue(Range("A32")) then
Selection.EntireRow.Hidden = True

End if``````

Friendly Regards
Herman

### Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college

#### Tetra201

##### MrExcel MVP
Try this:
Code:
``If Day(DateValue(Range("A32"))) = 1 Then Selection.EntireRow.Hidden = True``

#### Hmerman

##### Board Regular
Thank you very much, the date calculation works very well. I really like your style, it is understandable and clear as well as being effective.

I had to tweak my Hide command by selecting the Rows("32:32").

Here is my
Code:
``````If Day(DateValue(Range("A32"))) = 1 Then
Rows("32:32").EntireRow.Hidden = True
End If``````

Friendly Regards
Herman

#### MARK858

##### MrExcel MVP
@Hmerman, just a suggestion but you can just use the range again rather than use Rows i.e.

Code:
``````Sub hideit()

If Day(DateValue(Range("A32"))) = 1 Then Range("A32").EntireRow.Hidden = True

End Sub``````

or probably a better way of doing it...

Code:
``````Sub hideit2()
Dim rng As Range

Set rng = Range("A32")

If Day(DateValue(rng)) = 1 Then rng.EntireRow.Hidden = True

End Sub``````

but if you are using Rows then you don't need the .EntireRow as Rows already refers to the entire row i.e.

Code:
``````Sub hideit3()
If Day(DateValue(Range("A32"))) = 1 Then Rows("32:32").Hidden = True
End Sub``````

and as you see you don't need the End If's in any of the codes as you are only doing a single test and so it can all be on one line (as Tetra201 also did if you look at the code in post #2).

#### Hmerman

##### Board Regular
@MARK858

Sorry for not replying earlier. Was a bit swamped with work worries.

Thank you once again!

Friendly Regards

Replies
6
Views
303
Replies
8
Views
353
Replies
14
Views
389
Replies
3
Views
42
Replies
5
Views
112

1,129,800
Messages
5,638,430
Members
417,025
Latest member
MusterDuster

### 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.

### Which adblocker are you using?

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

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