Calendar Help

Ragarm13

New Member
Joined
Mar 25, 2018
Messages
19
I have a spreadsheet that works great, followed along with some instructions, but every time I switch months I must run a macro to make it update the days.
Is there a way to change this?
Attached is the VBA code
VBA Code:
[TABLE]
[TR]
[TD]Sub Hide_Day()
Dim Num_Col As Long
   'This instruction cleans the content of the cells in your calendar
   Range("B7:AF13").ClearContents
   For Num_Col = 30 To 32
   ' Test if the month of the cells (row 6) is the same of the month selected (cell A1 or cells(1,1))
     If Month(Cells(6, Num_Col)) <> Cells(1, 1) Then
        Columns(Num_Col).Hidden = True
     Else
        Columns(Num_Col).Hidden = False
     End If
   Next
End Sub[/TD]
[/TR]
[/TABLE]
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Hi, Sorry but didn't understand the requirement.

Great if you share an example to understand.

Thanks,
Saurabh
 
Upvote 0
Hi, Sorry but didn't understand the requirement.

Great if you share an example to understand.

Thanks,
Saurabh
I do not have the spreadsheet here at home, so I will try and explain.
A1 & A2 are inputs for Year and Month. Upon selecting the year and month my calendar updates days 1 - 31, depending on the month. When I am in month January, it displays all 31 Days. When I switch from January to February it displays days 1 - 28 plus days 1-3 of March. The VBA code haas a macro attached to it that I can run that hide the columns of days 1-3 of March. After I switch from March, to lets say April, I must once again run the macro to unhide the columns to show all of the days in April.
What I am wondering, is there a way to make this process "automatic" so that I do not have to run the macro every time I change the month. So if I select January, it will show all 31 days, and then if I select June, it will only show 30 by "automatically" hiding the last column.
 
Upvote 0
Ok, thanks for sharing details. Please share the macro to identify where the changes can be made.
 
Upvote 0

Forum statistics

Threads
1,213,531
Messages
6,114,167
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