View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
JMay JMay is offline
external usenet poster
 
Posts: 422
Default VBA and validation list

Paste this code into the specific Sheet module you want this to happen
on:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Application.Intersect(Target, Columns(1)) Is Nothing Then
With Target.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop,
Operator:= _
xlBetween, Formula1:="=TheGuys" 'This refers to an existing
Named Range
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
End If
End Sub

Worked for me...
Jim May



"John" wrote in message
:

Hi,

I have a validation list (H1:H5), I hope, using VBA, the list can
automatically attach itself to any cell in the first column of the worksheet
when the cell gets input focus.

How can I do this?

Thanks.