Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default Macro to set new data validation each time

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Macro to set new data validation each time

Instead, I would use d defined name for your validationlist and use that
name
insertnamedefinename itvallist
in the refers to box use an offset formula such as
=offset($a$1,0,0,counta($a:$a),1)
if blanks use something besides counta
Now, your list will be self adjusting.

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"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


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
How to use formula to decide when to apply TIME data validation Barbara T Excel Worksheet Functions 3 November 3rd 09 06:34 PM
Data Validation - Multiple Time Slots vimal Excel Programming 0 March 13th 07 02:01 PM
Time in data validation? Cymro Excel Worksheet Functions 1 June 8th 05 03:52 PM
time formatting and time categorizing (vlookup or data validation) MarianneR Excel Worksheet Functions 4 November 18th 04 03:24 PM
time formatting and time categorizing (vlookup or data validation) MarianneR Excel Worksheet Functions 0 November 18th 04 03:13 PM


All times are GMT +1. The time now is 10:14 PM.

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

About Us

"It's about Microsoft Excel"