? Possible for 'Button' to Reveal Hidden Rows (previously set up with relevant forumulae)

PurrSent

Board Regular
Joined
Jun 7, 2014
Messages
142
Using Excel 2010 and Windows 10 s1803

Hi

I’ve got a workbook with tabs: Summary / Jan / Feb / … / Dec

The Summary picks up the various row totals in each of the Month’s sheets

I will (potentially) need extra rows in each of the Monthly sheets so I have already set up, with formulae, these extra rows in each of the Monthly sheets, which I would like hidden until required.

I would like to have a cell, in each Monthly sheet, that I can just click on (similar to a link) that would reveal 1, or more, hidden row

Is this possible, please?

Assuming this would need VBA, would you please bear in mind that my knowledge of VBA is approx nil / very very limited. [I did do a semester on programming (Delphi) when doing Business IT degree, over 10 yrs ago, but had to work hard to grasp it ;) ]

Many thanks
 
Last edited:
Hi Tonyyy

I think I've cracked the Protected Sheet bit. Here is the code I've now got, by including a couple of lines, as you will see. This seems to work well, I'm pleased to say. Please let me know if you feel there is anything different I should be doing.

Code:
Sub unHideRows()

ActiveSheet.Unprotect Password:=""

Dim lastRow As Long, rws As Long, hiddenRow As Long
Dim r As Range
lastRow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row

For Each r In Range("A1:A" & lastRow).Rows
    If r.EntireRow.Hidden Then
        hiddenRow = r.Row
        Exit For
    End If
Next r
If hiddenRow > 0 Then
    rws = Application.InputBox(prompt:="Please enter the number of lines to unhide.", Type:=1)
    ActiveSheet.Rows(hiddenRow & ":" & hiddenRow + rws - 1).Hidden = False
Else
    MsgBox "There are no hidden rows."
End If

ActiveSheet.Protect Password:=""

End Sub

I took a guess at how to deal with no password, ie just not putting in a password, and it's working nicely, as I've said.

Many thanks for all your help with this :)
%
 
Upvote 0

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.

Forum statistics

Threads
1,223,909
Messages
6,175,312
Members
452,634
Latest member
cpostell

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