Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 22nd, 2011, 12:17 PM
Registered User
 
Join Date: Feb 2011
Posts: 5
Thanks: 1
Thanked 0 Times in 0 Posts
Unhappy Conditional hide columns

Hi All,

This is the newbie again.
What I want to do now is hide columns if a condition is met. The condition is in a drop-down box (named "CrossName") where the user selects if they want to use either an "Exact Match" cross reference or a "Convert Where Possible" cross reference table. What I want to do is this: if the user selects "Convert Where Possible", it HIDES a column that has a percentage drop-down (called "Percentage"), AND the group of columns that have the details of percentage breakdowns. If the user selects "Exact Match", both groups of columns should be visible.
I found some code in a tech manual that hides everything except a certain selection, but that's not what I'm looking for.
Can anyone help me here?

Thanks in advance!!
Leta

PS...Here's a little more that I have done...
in the top of the columns I want to hide, there is an "If" statement that says "If drop-down ="Exact", then =1, else =0". then my VBA runs as follows:

[Sub hidecolsif()
For Each c In Range("AT1:BQ1")
If c = 0 Then Columns(c.Column).Hidden = True
If c = 1 Then Columns(c.Column).Hidden = False
Next c
End Sub]

This mostly works. I just need it to run every time the drop-down is clicked.

Last edited by LWellman; March 22nd, 2011 at 01:08 PM..
 
Old March 22nd, 2011, 01:59 PM
Registered User
 
Join Date: Feb 2011
Posts: 5
Thanks: 1
Thanked 0 Times in 0 Posts
Talking

Never mind, I got it to work. Here's the code for those that want to do the same thing. The drop-down is in Cell AR9.

[Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$AR$9" Then
Call Sheet2.hidecolsif

End If

End Sub

Sub hidecolsif()
For Each c In Range("AT1:BQ1")
If c = 0 Then Columns(c.Column).Hidden = True
If c = 1 Then Columns(c.Column).Hidden = False
Next c
End Sub]





Similar Threads
Thread Thread Starter Forum Replies Last Post
Hide Columns, Filter & Copy Visable to new wrkbk dursta Excel VBA 1 June 4th, 2007 06:17 AM
Conditional display/hide of images bertvanpet Crystal Reports 0 May 25th, 2007 02:37 AM
hide/unhide columns in datagrid drachx ADO.NET 1 March 26th, 2005 01:46 PM
Conditional Hide Report Page Header SGL Access VBA 0 August 30th, 2004 02:36 PM
Resize and Hide columns in WEB FORM Datagrid? Ron Howerton Classic ASP Basics 5 April 30th, 2004 07:42 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.