Unhidden rows depending upon the secection of input

P

percy/pista/johnny

I am currently working on a project using Ms Excel. There are 50 Rows
on my excel sheet and i would like to hide some rows depending on the
inputs in other cells.

For e.g: In cells B31, the user selects one product from a drop down
list( A, B and C). Say the user selected products A, i want excel to
be able to unhidden everything that is related to A. i need code for
this..pls reply soon..its urgent
 
D

Don Guillett

You would probably use a worksheet_change event incorporating select case.
If desired, send your file to my address below along with this msg and clear
instructions.
 
M

meh2030

I am currently working on a project using Ms Excel. There are 50 Rows
on my excel sheet and i would like to hide some rows depending on the
inputs in other cells.

For e.g: In cells B31, the user selects one product from a drop down
list( A, B and C). Say the user selected products A,  i want excel to
be able to unhidden everything that is related to  A. i need code for
this..pls reply soon..its urgent

Percy/Pista/Johnny,

Your post is rather vague, so if you want a more concise answer,
please provide a more descriptive explanation along with any code you
have created; this will likely merit a better response from the group.

You can embed your code within the SelectionChange event to test
whether the drop down list has changed. (I'm assuming your drop down
is created from the data validation option). You can then run
ExecuteExcel4Macro to hide and unhide rows or columns (see sample code
below).

Best,

Matthew Herbert

Sub HideUnhide()

Dim rngExpand As Range
Dim strExecute As String

'create a range object to work with
Set rngExpand = Range("A2")

'--------------------------------------------------------------
'General Comments for hiding and unhiding groupings
'
'Show.Detail
' Arg1 = 1 (Row) or 2 (Column)
' Arg2 = Row or Column inside of or including the +/- outline
' Arg3 = True (Unhide) or False (Hide)
'
'--------------------------------------------------------------

'unhide a grouping
strExecute = "Show.Detail(1," & rngExpand.Row & ",True)"
ExecuteExcel4Macro strExecute

'hide a grouping
strExecute = "Show.Detail(1," & rngExpand.Row & ",False)"
ExecuteExcel4Macro strExecute

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top