View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson[_2_] Dave Peterson[_2_] is offline
external usenet poster
 
Posts: 420
Default associate "pick box"

The code used would depend on what you're using.

If you're using Data|Validation, a combobox from the Control toolbox toolbar or
a dropdown from the Forms toolbar, then the code would be different.

If you used Data|Validation, you could use a worksheet event (depending on the
version of excel that you have to support) to clear the contents of the cells
that are "down the chain" from that cell.

This looks at changes in A1:D1.

If the change is made in A1, then B1:D1 is cleared.
If the change is made in B1, then C1:D1 is cleared.
If the change is made in C1, then D1 is cleared.

Since this is a worksheet event, the code is placed in the worksheet module that
should have this behavior.

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count 1 Then
Exit Sub 'single cell at a time
End If

On Error GoTo ErrHandler:
With Target
If Not (Intersect(.Cells, Me.Range("A1")) Is Nothing) Then
'change in A1, clear B1:D1 (say)
Application.EnableEvents = False
Me.Range("b1:D1").ClearContents
ElseIf Not (Intersect(.Cells, Me.Range("b1")) Is Nothing) Then
'change in b1, clear c1:D1 (say)
Application.EnableEvents = False
Me.Range("c1:D1").ClearContents
ElseIf Not (Intersect(.Cells, Me.Range("c1")) Is Nothing) Then
'change in c1, clear D1 (say)
Application.EnableEvents = False
Me.Range("D1").ClearContents
Else
'do nothing
End If
End With

ErrHandler:
On Error Resume Next
Application.EnableEvents = True

End Sub

On 05/18/2010 21:36, Richard R wrote:
If you wish to present a user with a restricted choice of options and don't
want to risk an item being miss-typed in a cell, drop down lists are an ideal
solution. These lists display all of the available choices to the user so
that they can click on their preference. Excel allows you to place two
different types of drop down list on your worksheet - either a validation
list or a form object.



"Gord Dibben" wrote:

What is a "pick box"?


Gord Dibben MS Excel MVP

On Tue, 18 May 2010 09:09:01 -0700, Richard R
wrote:

I need a bit of VBA code I believe or an inventive way to make "pick boxes"
associative, just like a cell would be if you dragged accross a field. what
is happening to me is that the new pick boxes all refer back to the original
true false field, leaving my data selection random.


.