TheSkaBoss
New Member
- Joined
- Aug 12, 2014
- Messages
- 5
The spreadsheet we use at my office is clunky in a number of ways. I recently joined the company, and I'm trying to clean things up for them. I dabble in Excel, but I'm no guru, which is why I need your help. We use Excel 2010.
Right now in the model, the team can look at up to 225 sites for evaluating the deals we work. The hard part is, users have to manually hide columns they don't want to see. It can take forever to scroll below the site list to see the other useful information.
My goal is to create an input cell where users can type in however many sites they have, and it will show/hide rows accordingly. So, for example, if I input 3 in that cell, rows 14-16 would display, and rows 17-238 would be Hidden. But suppose 1 more site comes into the mix, and so I change the input value to 4, then row 17 would be Unhidden, while the rest stay Hidden. It seems like it shouldn't be that complicated, but I can't figure it out.
If I recall correctly, I'll have to use two macros, with the first one Calling the second, based on the value of the cell changing.
I think I'll need to create a Dynamic Named Range from X:238 that changes based on the number chosen. For example, if 1 is chosen, then X would be 15, for row 15. If I chose 3, then X would be 17, for row 17. That way it hides rows X:238. I'm looking into how to do this, but no luck yet.
So right now I have the dropdown/input cell named NumberOfSites. When that value changes, it should trigger the macro SiteNumberSelection
So I have that part, but it doesn't seem to do much.
I know there is a way to do this, but I'm just not putting two and two together here, it seems like. Can anyone help me figure this out?
Right now in the model, the team can look at up to 225 sites for evaluating the deals we work. The hard part is, users have to manually hide columns they don't want to see. It can take forever to scroll below the site list to see the other useful information.
My goal is to create an input cell where users can type in however many sites they have, and it will show/hide rows accordingly. So, for example, if I input 3 in that cell, rows 14-16 would display, and rows 17-238 would be Hidden. But suppose 1 more site comes into the mix, and so I change the input value to 4, then row 17 would be Unhidden, while the rest stay Hidden. It seems like it shouldn't be that complicated, but I can't figure it out.
If I recall correctly, I'll have to use two macros, with the first one Calling the second, based on the value of the cell changing.

I think I'll need to create a Dynamic Named Range from X:238 that changes based on the number chosen. For example, if 1 is chosen, then X would be 15, for row 15. If I chose 3, then X would be 17, for row 17. That way it hides rows X:238. I'm looking into how to do this, but no luck yet.
So right now I have the dropdown/input cell named NumberOfSites. When that value changes, it should trigger the macro SiteNumberSelection
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim KeyCells As Range
Set KeyCells = Range("NumberOfSites")
Call SiteNumberSelection
End Sub
So I have that part, but it doesn't seem to do much.
Code:
Sub SiteNumberSelection()
'
' SiteNumberSelection Macro
' Shows the number of rows that corresponds with sites to be modeled
'
'
Range("NumberOfSites").Select
ActiveCell.FormulaR1C1 = "4"
Rows("18:238").EntireRow.Hidden = True
End Sub
I know there is a way to do this, but I'm just not putting two and two together here, it seems like. Can anyone help me figure this out?