Drilling down in excel

baggarwal

Well-known Member
Joined
Jul 10, 2002
Messages
591
Hi All:

In the spreadsheet attached, what I want to do is setup a drilldown so that if someone clicks a cell with a value in it, it will show everything that makes up that number.
Book1
ABCD
3Relay2201
4PR1500
5HW100
6SW200
7Consulting200
8PR2678
9TR1567
10TR2456
Sheet1


So in the example attached. I want to setup the spreadsheet so that if someone double clicks cell B3, which is $2,201 then everything that makes it up...i.e cells B4, B8, B9 and B10 are shown otherwise hidden. If someone wants to double click B4 then I want cell cells A5 to B7 to show up.

Can someone please help work through this.

Thanks,

BA
 
You asked for 2 scenarios so here they are, one for B3 and one for B4.

Be careful with this, it literally does what you want, which is to only show a small visible range, but in so doing it hides about 16,777,210 other cells, albeit clumped in column abd row ranges, but still, depending on your system resources, can have an effect on memory. Excel is a 2-dimensional program (height in rows and width in columns), so the sequence of the code is to unhide everything, then selectively re-hide what you don't want to see.

It would be better to limit the scroll area to where you want your user to go when they have drilled down, instead of all this hiding. or, maybe dialog boxes or user forms would be more efficient to show the drilled down information. All options are your decision...here's what you literally requested:

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Select Case Target.Address
'To show only A102:B105
Case "$B$3"
If Target = "" Then
Cancel = True
Else
Application.ScreenUpdating = False
Cells.EntireRow.Hidden = False
Cells.EntireColumn.Hidden = False
Range("C:IV").EntireColumn.Hidden = True
Range("1:101,106:65536").EntireRow.Hidden = True
Application.ScreenUpdating = True
Cancel = True
End If
'To show only A102:A105 and C102:C105
Case "$B$4"
Application.ScreenUpdating = False
Cells.EntireRow.Hidden = False
Cells.EntireColumn.Hidden = False
Range("B:B,D:IV").EntireColumn.Hidden = True
Range("1:101,106:65536").EntireRow.Hidden = True
Application.ScreenUpdating = True
Cancel = True
Case Else
Exit Sub
End Select
End Sub
 
Upvote 0

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).

Forum statistics

Threads
1,215,201
Messages
6,123,621
Members
449,109
Latest member
Sebas8956

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