Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2
Default How to do: If 'yes', then show extra columns

How can I set up my excel sheet so that if the user enters 'yes' next to a
question, then 2 extra columns are shown? Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default How to do: If 'yes', then show extra columns

You'll need a macro to do the work. Maybe you could use a worksheet_change
event that looks for changes that the user types in. Then reacts and does
something.

If you want to try:
rightclick on the worksheet tab that should have this behavior. Select view
code and paste this into that new code window.

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)

Dim myRngToCheck As Range
Dim myCell As Range

Set myRngToCheck = Me.Range("c3, f3, k3")

If Intersect(Target, myRngToCheck) Is Nothing Then Exit Sub

On Error Resume Next 'just skip any errors
Application.EnableEvents = False
For Each myCell In myRngToCheck.Cells
myCell.Offset(0, 1).Resize(1, 2).EntireColumn.Hidden _
= CBool(LCase(myCell.Value) = "yes")
Next myCell
Application.EnableEvents = True
On Error GoTo 0

End Sub

I unhid the two columns just to the right of the cell that changed.

mgirving wrote:

How can I set up my excel sheet so that if the user enters 'yes' next to a
question, then 2 extra columns are shown? Thanks.


--

Dave Peterson
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
adding extra digits to columns Graham at Mac's Excel Discussion (Misc queries) 2 August 21st 06 11:24 AM
adding extra digits to columns Muhammed Rafeek M Excel Discussion (Misc queries) 0 August 21st 06 10:35 AM
Extra Columns Peco Worker Excel Discussion (Misc queries) 3 May 23rd 05 01:17 PM
formula to show ranges in columns Lori Excel Worksheet Functions 7 May 23rd 05 12:44 PM
add a column to a pivot table that would show the difference between 2 other Columns [email protected] Excel Worksheet Functions 7 January 30th 05 05:21 PM


All times are GMT +1. The time now is 11:38 AM.

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

About Us

"It's about Microsoft Excel"