Hiding rows issue

Jemmi

New Member
Joined
Jun 18, 2014
Messages
12
End goal:
To enter a numeric value in a cell, and according to the value, it will hide all rows based on different values in a set column.

Example:
Enter 4 in cell B2 and it will hide all rows which contain values "AB5, AB6, AB7, AB8" in column P.

What i've tried:
VBA code, but i can only get it to work through defining which rows I want to hide, which is a problem as I have over 16000 rows of data. I'd like it to work dynamically dependant on the value in column P:


Code:
[TABLE="width: 65"]
<tbody>[TR]
[TD]Sub worksheet_change(ByVal target As Range)[/TD]
[/TR]
[TR]
[TD]If Not Intersect(target, Range("B2")) Is Nothing Then[/TD]
[/TR]
[TR]
[TD]    ActiveSheet.Rows("10:20000").EntireRow.Hidden = False[/TD]
[/TR]
[TR]
[TD]    If target = 1 Then[/TD]
[/TR]
[TR]
[TD]        ActiveSheet.Rows("12:18").EntireRow.Hidden = True[/TD]
[/TR]
[TR]
[TD]    ElseIf target = 2 Then[/TD]
[/TR]
[TR]
[TD]        ActiveSheet.Rows("13:18").EntireRow.Hidden = True[/TD]
[/TR]
[TR]
[TD]    ElseIf target = 3 Then[/TD]
[/TR]
[TR]
[TD]        ActiveSheet.Rows("14:18").EntireRow.Hidden = True[/TD]
[/TR]
[TR]
[TD]    ElseIf target = 4 Then[/TD]
[/TR]
[TR]
[TD]        ActiveSheet.Rows("15:18").EntireRow.Hidden = True[/TD]
[/TR]
[TR]
[TD]    ElseIf target = 5 Then[/TD]
[/TR]
[TR]
[TD]        ActiveSheet.Rows("16:18").EntireRow.Hidden = True[/TD]
[/TR]
[TR]
[TD]    ElseIf target = 6 Then[/TD]
[/TR]
[TR]
[TD]        ActiveSheet.Rows("17:18").EntireRow.Hidden = True[/TD]
[/TR]
[TR]
[TD]    ElseIf target = 7 Then[/TD]
[/TR]
[TR]
[TD]    End If[/TD]
[/TR]
</tbody>[/TABLE]



Conditional formatting may be a solution I haven't looked into yet, but really i'd to be able to type in a number and I see the information I need, enabling me to copy this to another sheet/document. I'd really appreciate any pointers on the best way of doing this, thanks.
 

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.

Forum statistics

Threads
1,223,908
Messages
6,175,304
Members
452,633
Latest member
DougMo

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