how to I hide the rows of the current month as the days are not in this month

mmsamaddar

New Member
Joined
May 26, 2015
Messages
14
Hi,

Please help me: how to I hide the rows of the current month as the days are not in this month. As an example: I have 31 rows for days of month, but when I have to work for the month of April-the 31st row will hide automatically. Is it possible????
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Re-do...
 
Last edited:
Upvote 0
Hi mmsamaddar,

Since I did not know where on your worksheet the rows you want to hide are, this code will hide the row numbers that correspond to the number of days in the current month. Please adjust to fit your circumstance. Place this code in the worksheet module.

Code:
Private Sub Worksheet_Activate()

    Dim x As Integer
         
    x = Day(DateSerial(Year(CDate(Date)), Month(CDate(Date)) + 1, 1) - 1)
    Rows("1:31").EntireRow.Hidden = True
    Rows("1:" & x).EntireRow.Hidden = False
    
End Sub

HTH

igold
 
Upvote 0
Thanks to reply, I can't understand, would you please explain? If I could send the attachment, I am sure, it solved.

I have a sheet1, A4=Starting Date (1-Feb-15), A34= Last date(3-Mar-15), I need to hide automatically the rows of March ie 32,33,34 number row.
 
Upvote 0
I have sent the file back to you. Please confirm receipt and that it works as required.

igold
 
Upvote 0
Dear igold,

I received the file and sorry to say that, it didn't work for me, I want: When I will select 1st Date of current month on cell C4, only the Rows of current month's date will be visible in the month. Such as: When I select 1-Jun-2015, 44 no Row will be hidden as the cell contains the 1st day of next month. After selecting date 1-Feb-2015, 42,43 & 44 No.of row will be hidden, but when I select 1-Dec-2015, All the rows from 14:44 will be visible.
Can I make you clear my problem. If I could, Please help me sending the attachment.

Thanks
Madhu
 
Upvote 0
Madhu,

Ok, I misunderstood your request. I thought you wanted the change to occur when you first opened the workbook. I have now changed it so that every time you change cell C4 the Rows/Days will update. I have sent you the file.

Please let me know if this works for you.

igold
 
Upvote 0
Hi Dear, It works like charm what I expected. Thanks igold and I am very grateful to you. I will come to you soon to get more tips.

Thanks again.
 
Upvote 0
One problem, If I protect the sheet, the cell where I input some data, a pop up message warning:
Microsoft Visual Basic
Run-time error '1004':
Unable to set the Hidden property of the Range class
Continue(blind) End Debug Help

Can it be solved anyway with sheet password protection???
 
Upvote 0
Madhu,

As far as I know, if a sheet is password protected it prevents code from being run properly. Usually when you have code that you want to run on a protected sheet, there are commands in the code that first unprotects the sheet and then at the end of the code enables the protection again. I will see if that can be done with what I gave you, but I have my doubts.

igold
 
Upvote 0

Forum statistics

Threads
1,214,959
Messages
6,122,476
Members
449,087
Latest member
RExcelSearch

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