View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Otto Moehrbach[_2_] Otto Moehrbach[_2_] is offline
external usenet poster
 
Posts: 1,071
Default Macro to set new data validation each time

Munchkin
I would name the list range something like "TheList". Then setup the
Data Validation cell, select List, and in the Source block put "=TheList"
without the quotes. Then place the following macro in the sheet module of
your sheet. To access that module, right-click the sheet tab, select View
Code. "X" out of the module to return to your sheet..
This macro will reset the range "TheList" whenever the user select (clicks
on) D6. Post back if you need more. HTH Otto
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Count 1 Then Exit Sub
If Not Intersect(Target, Range("D6")) Is Nothing Then
Range("A1", Range("A" & Rows.Count).End(xlUp)).Name = "TheList"
Range("D5").Select
End If
End Sub
"Munchkin" wrote in message
...
I need my macro to reset the data validation for D6 each time it is run as
the range of rows will increase as new info is added. How can I do this?

Range("D6").Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=
_
xlBetween, Formula1:="=$A$1:$A$547"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With