Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I like to be able to hide/unhide colums based on a dropdown lis
selection The 1st column starts in K and the 7th column in Q If dropdown selection = 1, then hide columns L to Q, show columns If dropdown selection = 2, then hide columns M to Q, show columns K- Etc til If dropdown selection = 2, then show columns K to Is there a way to do this in VBA. I've been trying to do this bu without any success Any help is appreciated Michae -------- Message sent via www.excelforums.com |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Michael,
Adapt the following ------ Private Sub Selection_Change() 'selection.value , 'selection = the dropdown boxes name Select Case Selection.Value Case 1 Worksheets("Data").Range("a1:c1").EntireColumn.Hid den = True Worksheets("Data").Range("d1:e1").EntireColumn.Hid den = False Case 2 Worksheets("Data").Range("a1:c1").EntireColumn.Hid den = False Worksheets("Data").Range("d1:e1").EntireColumn.Hid den = True Case 3 End Select End Sub ---- David |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
David
I've modified your code. But I get the [quote:66f5bed38c Object Required[/quote:66f5bed38c] error message. and it already stop at Select Cas DropDown125.Valu The name of the dropdown is DropDown12 This is the first time I'm trying VBA so sorry for an stupid questions :oops: [code:1:66f5bed38c]Sub DropDown125_Change( Select Case DropDown125.Valu Case Worksheets("Data").Range("l1:q1").EntireColumn.Hid de = Tru Worksheets("Data").Range("k1:k1").EntireColumn.Hid de = Fals Case Worksheets("Data").Range("k1:l1").EntireColumn.Hid de = Fals Worksheets("Data").Range("m1:q1").EntireColumn.Hid de = Tru Case Worksheets("Data").Range("k1:m1").EntireColumn.Hid de = Fals Worksheets("Data").Range("n1:q1").EntireColumn.Hid de = Tru Case Worksheets("Data").Range("k1:n1").EntireColumn.Hid de = Fals Worksheets("Data").Range("o1:q1").EntireColumn.Hid de = Tru Case Worksheets("Data").Range("k1:o1").EntireColumn.Hid de = Fals Worksheets("Data").Range("p1:q1").EntireColumn.Hid de = Tru Case Worksheets("Data").Range("k1:p1").EntireColumn.Hid de = Fals Worksheets("Data").Range("r1:q1").EntireColumn.Hid de = Tru Case Worksheets("Data").Range("k1:q1").EntireColumn.Hid de = Fals End Selec End Su [/code:1:66f5bed38c][/i -------- Message sent via www.excelforums.com |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Okay the problem is probably this.
I ran my code from a userform and you are probably using a dropdown box on a worksheet This is what you need to change to set the object ------------------- Sub DropDown125_Change() Dim r As Double With Worksheets("Data") r = .DropDowns("drop down 125").Value End With Select Case r Case 1 'code as you have End --------------- Hope this solves the problem "mgronov - ExcelForums.com" wrote in message ... David, I've modified your code. But I get the [quote:66f5bed38c] Object Required[/quote:66f5bed38c] error message. and it already stops |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Creating a dropdown list based on selection from a differernt drop | Excel Discussion (Misc queries) | |||
Drop down list based on choice of another dropdown | Excel Discussion (Misc queries) | |||
Get matching values and formulas from ajoining colums of dropdown | Excel Discussion (Misc queries) | |||
offer dropdown options based on another dropdown | Excel Discussion (Misc queries) | |||
Hide Columns based on a Data Validation List | Excel Programming |