Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Adding a validation list by code

Hi all,

I would like to install a validation list by code.
I get a snippet using the macro recorder.(see below)
However when I run the code, 2 problems ocur:
1- the list will not show 2 choices: YES and NO, but only one: YES;NO
2- YES is not selected, although I selected it during the recording of
the macro
Do you know how I should improve the code to have it do what I need?
TIA,
Philippe


With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=
_
xlBetween, Formula1:="YES;NO"
.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: 27,285
Default Adding a validation list by code

Sub AA()
With Selection.Validation
.Delete
.Add Type:=xlValidateList, _
AlertStyle:=xlValidAlertStop, _
Operator:=xlBetween, _
Formula1:="YES,NO"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
Selection.Value = "Yes"
End Sub

the only way to select it is to enter that value in the cell.

--
Regards,
Tom Ogilvy

"Philippe Pons" wrote in message
...
Hi all,

I would like to install a validation list by code.
I get a snippet using the macro recorder.(see below)
However when I run the code, 2 problems ocur:
1- the list will not show 2 choices: YES and NO, but only one: YES;NO
2- YES is not selected, although I selected it during the recording of
the macro
Do you know how I should improve the code to have it do what I need?
TIA,
Philippe


With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop,

Operator:=
_
xlBetween, Formula1:="YES;NO"
.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: 4
Default Adding a validation list by code

Thank's Tom, I'll test it.
Philippe


"Tom Ogilvy" a écrit dans le message de
...
Sub AA()
With Selection.Validation
.Delete
.Add Type:=xlValidateList, _
AlertStyle:=xlValidAlertStop, _
Operator:=xlBetween, _
Formula1:="YES,NO"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
Selection.Value = "Yes"
End Sub

the only way to select it is to enter that value in the cell.

--
Regards,
Tom Ogilvy

"Philippe Pons" wrote in message
...
Hi all,

I would like to install a validation list by code.
I get a snippet using the macro recorder.(see below)
However when I run the code, 2 problems ocur:
1- the list will not show 2 choices: YES and NO, but only one:

YES;NO
2- YES is not selected, although I selected it during the recording

of
the macro
Do you know how I should improve the code to have it do what I need?
TIA,
Philippe


With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop,

Operator:=
_
xlBetween, Formula1:="YES;NO"
.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
Adding to a data validation list Josh Craig Excel Discussion (Misc queries) 2 June 30th 09 02:59 AM
Validation List - adding new entries watermt Excel Worksheet Functions 20 March 27th 09 10:06 PM
Validation list after adding a calendar Michael B Excel Discussion (Misc queries) 0 November 13th 08 09:36 AM
Validation List -adding data and using it later POC Excel Discussion (Misc queries) 1 July 23rd 06 05:40 AM
adding a list validation to a cell Phil Sobolik Excel Programming 3 October 9th 03 01:53 AM


All times are GMT +1. The time now is 05:19 AM.

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

About Us

"It's about Microsoft Excel"