View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson Dave Peterson is offline
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