Hid up to 100 individual rows from cell in another sheet

SReilly

New Member
Joined
Nov 18, 2015
Messages
4
Hello there,

Looking for a bit of help at hiding rows in a sheet called "Summary" based on cell E35 in a sheet called "Basics".
I can get this to work using the code below the problem is that I will want the value to go to 100 and up to 100 rows (from row 24 on) to be hidden. WI'd also like all rows to be unhidden if E35 is blank. Would anyone have any suggestions on how this is possible using a loop function?:confused:

Code:
Private Sub Worksheet_Calculate()
 Dim Summaries,As Range

 Set Summaries = Sheets("Basics").Range("E35")
  
 If Summaries.Value = "1" Then
 Sheets("Summary").Rows("23:23").EntireRow.Hidden = False
 Sheets("Summary").Rows("24:32").EntireRow.Hidden = True
 
 ElseIf Summaries.Value = "2" Then
 Sheets("Summary").Rows("23:24").EntireRow.Hidden = False
 Sheets("Summary").Rows("25:32").EntireRow.Hidden = True
 
 ElseIf Summaries.Value = "3" Then
 Sheets("Summary").Rows("23:25").EntireRow.Hidden = False
 Sheets("Summary").Rows("26:32").EntireRow.Hidden = True

 Else
 Sheets("Summary").Rows("23:32").EntireRow.Hidden = False

 End If
 End Sub

Thanks so much for your help!
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Give this a try
Code:
Private Sub Worksheet_Calculate()
 Dim cnt As Long
 cnt = Sheets("Basics").Range("E35").Value
 If cnt > 0 Then
    Sheets("Summary").Rows("23:" & 22 + cnt).Hidden = False
    Sheets("Summary").Rows(23 + cnt & ":100").Hidden = True
 Else
    Sheets("Summary").Rows("23:100").Hidden = False
 End If
 End Sub
 
Upvote 0
Thanks so much for your quick reply JLGWhiz - it looks so simple when you see it like that!
I wish I could think of these things :biggrin: More practise needed I guess!
Thanks again JLGWhiz, really appreciate it!
 
Upvote 0
Thanks so much for your quick reply JLGWhiz - it looks so simple when you see it like that!
I wish I could think of these things :biggrin: More practise needed I guess!
Thanks again JLGWhiz, really appreciate it!

You're welcome,
regards, JLG
 
Upvote 0

Forum statistics

Threads
1,223,991
Messages
6,175,820
Members
452,672
Latest member
missbanana

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