Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default How to mention a range of validation list in VBA?

Dear all experts,

I create a named validation list called "chuen_PN" via marco recording on
worksheet1 with the similar code like following:
.......
Range("A1:C12").Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=
_
xlBetween, Formula1:="=chuen_PN"
.IgnoreBlank = True
.InCellDropdown = True
......
......
......

Remark * ( soruce of chuen_PN is in different worksheet of the same workbook
..)

Now I want to use VBA code to point the range instead of the named
(chuen_PN) , but it's failed when I change the code like following..

......
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="worksheet(index).range("A1:A12")"
.IgnoreBlank = True
.InCellDropdown = True
......

Can I define a range by VBA code (worksheet(index).range......) in
validation list here?

Thanks all




  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default How to mention a range of validation list in VBA?

Norika,
it's not a programming problem:

data validation does not allow a range on a different worksheet.
you MUST go via a defined name aka "named range".

--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


norika wrote :

Dear all experts,

I create a named validation list called "chuen_PN" via marco
recording on worksheet1 with the similar code like following:
......
Range("A1:C12").Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop,
Operator:= _
xlBetween, Formula1:="=chuen_PN"
.IgnoreBlank = True
.InCellDropdown = True
......
......
......

Remark * ( soruce of chuen_PN is in different worksheet of the same
workbook .)

Now I want to use VBA code to point the range instead of the named
(chuen_PN) , but it's failed when I change the code like following..

......
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="worksheet(index).range("A1:A12")"
.IgnoreBlank = True
.InCellDropdown = True
......

Can I define a range by VBA code (worksheet(index).range......) in
validation list here?

Thanks all

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,120
Default How to mention a range of validation list in VBA?

If the DV is pointing to another worksheet, you have to use a name to
reference through. If it is not, you don't need the worksheet name.

--
HTH

Bob Phillips

"norika" wrote in message
...
Dear all experts,

I create a named validation list called "chuen_PN" via marco recording on
worksheet1 with the similar code like following:
......
Range("A1:C12").Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop,

Operator:=
_
xlBetween, Formula1:="=chuen_PN"
.IgnoreBlank = True
.InCellDropdown = True
......
......
......

Remark * ( soruce of chuen_PN is in different worksheet of the same

workbook
.)

Now I want to use VBA code to point the range instead of the named
(chuen_PN) , but it's failed when I change the code like following..

......
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="worksheet(index).range("A1:A12")"
.IgnoreBlank = True
.InCellDropdown = True
......

Can I define a range by VBA code (worksheet(index).range......) in
validation list here?

Thanks all






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
Data validation list using filtered range michaelberrier Excel Discussion (Misc queries) 3 March 2nd 11 12:13 AM
Data Validation - List - Setting Range from a macro dhstein Excel Discussion (Misc queries) 5 May 14th 09 01:11 PM
Question about range in validation list Hank Excel Discussion (Misc queries) 2 March 13th 09 08:24 PM
Edit validation list range Kim K Excel Discussion (Misc queries) 2 November 1st 06 06:44 PM
data validation list selected from a range Native Excel Discussion (Misc queries) 11 January 20th 06 01:11 AM


All times are GMT +1. The time now is 08:53 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"