How can I display selected worksheet areas with command buttons?

Nikko

Board Regular
Joined
Nov 26, 2018
Messages
73
Hello,

Would like to have worksheet sections displayed by command buttons, but I do not know how to do it.

In the worksheet the month range should be displayed by clicking on the respective button.
So that the respective desired month after column G appears (column A to G should always be displayed with). Example Column from A to G fixed and after column G the respective beginning of the month should appear as column AM for February. The whole area should not be selected at the end.

07f43e-1547746169.jpg
[/URL][/IMG]

Thx in Advance :-)
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Hi jim,
Thank you for your suggestion.
But this is not what I am looking for or need. Would like to accomplish all this with VBA and Command Buttons (see picture).
Need actual support for the VBA code, as I can write and install this in a command button.

Any idea how to do it?
 
Upvote 0
Here is the Code behind your January Button (Only). You can create the Same MODIFIED- CODE for the Feb - Dec Buttons (the other 11)

Code:
Private Sub CommandButton1_Click() ' To Show ONLY your Janaury Columns
Application.ScreenUpdating = False
With ActiveSheet
    .Range("H:NH").EntireColumn.Hidden = False  'Always Unhides All your Columns from your previous action
    .Range("AM:NH").EntireColumn.Hidden = True   ' Displays the month of January ONLY
End With
Application.ScreenUpdating = True
End Sub

[TABLE="width: 216"]
<tbody>[TR]
[TD="width: 72"][/TD]
[TD="class: xl63, width: 144, colspan: 2"]*** COLUMN LETTERS ***[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="class: xl65"]Start[/TD]
[TD="class: xl65"]End[/TD]
[/TR]
[TR]
[TD]Jan[/TD]
[TD="class: xl66"]H[/TD]
[TD="class: xl66"]AL[/TD]
[/TR]
[TR]
[TD]Feb[/TD]
[TD="class: xl66"]AM[/TD]
[TD="class: xl66"]BN[/TD]
[/TR]
[TR]
[TD]Mar[/TD]
[TD="class: xl66"]BO[/TD]
[TD="class: xl66"]CS[/TD]
[/TR]
[TR]
[TD]Apr[/TD]
[TD="class: xl66"]??[/TD]
[TD="class: xl66"]??[/TD]
[/TR]
[TR]
[TD]May[/TD]
[TD="class: xl66"]??[/TD]
[TD="class: xl66"]??[/TD]
[/TR]
[TR]
[TD]Jun[/TD]
[TD="class: xl66"]??[/TD]
[TD="class: xl66"]??[/TD]
[/TR]
[TR]
[TD]Jly[/TD]
[TD="class: xl66"]??[/TD]
[TD="class: xl66"]??[/TD]
[/TR]
[TR]
[TD]Aug[/TD]
[TD="class: xl66"]??[/TD]
[TD="class: xl66"]??[/TD]
[/TR]
[TR]
[TD]Sep[/TD]
[TD="class: xl66"]??[/TD]
[TD="class: xl66"]??[/TD]
[/TR]
[TR]
[TD]Oct[/TD]
[TD="class: xl66"]??[/TD]
[TD="class: xl66"]??[/TD]
[/TR]
[TR]
[TD]Nov[/TD]
[TD="class: xl66"]??[/TD]
[TD="class: xl66"]??[/TD]
[/TR]
[TR]
[TD]Dec[/TD]
[TD="class: xl66"]??[/TD]
[TD="class: xl66"]NH[/TD]
[/TR]
</tbody>[/TABLE]
 
Last edited:
Upvote 0
Here's the Code that should be BEHIND the February Button...

Code:
Private Sub CommandButton2_Click()     ' Show ONLY February
Application.ScreenUpdating = False
With ActiveSheet
    .Range("H:NH").EntireColumn.Hidden = False  'Always Unhides All your Columns
    .Range("H:AL,BO:NH").EntireColumn.Hidden = True
End With
Application.ScreenUpdating = True
End Sub
 
Upvote 0
Hi jim may,

big thank you for your effort.
Will try it tomorrow and let you know how it went.

Thanks again for your effort and patience with me :-)
 
Upvote 0
Hi jim may,

its works :-)

Can not thank enough :-)

A hero is one who does what he can. The others do not do it. (Romain Rolland)
 
Upvote 0

Forum statistics

Threads
1,224,824
Messages
6,181,186
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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