Macro to hide cells

abutler1986

New Member
Joined
Mar 11, 2015
Messages
34
Hi All,

My VB coding lets me down every time so I hoping someone can help me again.

I have some cells I need to be hidden / shown based on a macro button which also needs to be password protected.

The cells I need hidden are B27:E27 then "L10:R10 - L17:E17"

It is just in one worksheet.

Any additional information needed please let me know.

Andrew
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
What do you mean by hiding cells?

Do you want to hide the columns B:E
The cells I need hidden are B27:E27

And the columns L:R and the rows 10:17?
then "L10:R10 - L17:E17"

As far as I know it's not possible to hide cells. Only columns/rows and formulas inside cells.

This code will hide/show the columns and rows given a password:
Code:
Sub click_button()
Dim key As String
Do Until key = "your password"
    key = InputBox(Prompt:="Enter password", Title:="Enter password", Default:="Type here")
    If key = vbNullString Then
        Exit Sub
    Else: End If
Loop


With ActiveSheet
    If .Columns("B:E").Hidden = True And Columns("L:R").Hidden = True And .Rows("10:17").Hidden = True Then
        .Columns("B:E").Hidden = False
        .Columns("L:R").Hidden = False
        .Rows("10:17").Hidden = False
    Else
        .Columns("B:E").Hidden = True
        .Columns("L:R").Hidden = True
        .Rows("10:17").Hidden = True
    End If
End With


End Sub
 
Last edited:
Upvote 0
Thanks for the information, I have decided to create a different tab but the information you provided will certainly help me in future projects so for that I am grateful :)

Regards,

Andrew
 
Upvote 0

Forum statistics

Threads
1,214,648
Messages
6,120,725
Members
448,987
Latest member
marion_davis

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