Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Hide colums based on dropdown list

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 61
Default Hide colums based on dropdown list

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Hide colums based on dropdown list

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 61
Default Hide colums based on dropdown list

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Hide colums based on dropdown list

David
You rock! It works great :D
Thanks

Michae
--------
Message sent via www.excelforums.com
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating a dropdown list based on selection from a differernt drop Joey Spreadsheets Excel Discussion (Misc queries) 3 May 23rd 09 09:16 PM
Drop down list based on choice of another dropdown Amy Excel Discussion (Misc queries) 2 January 23rd 08 08:39 PM
Get matching values and formulas from ajoining colums of dropdown Pete Elbert Excel Discussion (Misc queries) 1 March 18th 06 05:49 AM
offer dropdown options based on another dropdown Conor Excel Discussion (Misc queries) 2 January 13th 06 04:28 PM
Hide Columns based on a Data Validation List Ricky Pang Excel Programming 4 September 15th 04 02:43 AM


All times are GMT +1. The time now is 07:54 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"