PC Review


Reply
Thread Tools Rate Thread

data validation syntax

 
 
Nigel
Guest
Posts: n/a
 
      17th Nov 2006
im having trouble figuring out what is wrong with this code....
it should use the range set to the variable ProdRange as the source for
the data, and putting the drop down list in cell A3.....

Dim ProdRange As Range
Set ProdRange = Range("a7", "a" & Range("EndOfProducts").Offset(-2,
0).Row)
Range("a3").Validation.Add xlValidateList, , , "=" &
ProdRange.Address

anyone know what im doing wrong?

 
Reply With Quote
 
 
 
 
=?Utf-8?B?SkxHV2hpeg==?=
Guest
Posts: n/a
 
      17th Nov 2006
Your problem is in this line:
Set ProdRange = Range("a7", "a" & Range("EndOfProducts").Offset(-2, 0).Row)
Maybe should be:
Set ProdRange = Range("a7":"a" & Range("EndOfProducts").Offset(-2, 0).Row)
"Nigel" wrote:

> im having trouble figuring out what is wrong with this code....
> it should use the range set to the variable ProdRange as the source for
> the data, and putting the drop down list in cell A3.....
>
> Dim ProdRange As Range
> Set ProdRange = Range("a7", "a" & Range("EndOfProducts").Offset(-2,
> 0).Row)
> Range("a3").Validation.Add xlValidateList, , , "=" &
> ProdRange.Address
>
> anyone know what im doing wrong?
>
>

 
Reply With Quote
 
wisccal@googlemail.com
Guest
Posts: n/a
 
      17th Nov 2006
What exactly is the problem you are experiencing? You might need to
delete the Validation right before you add it:

With Range("a3").Validation
.Delete
.Add ...
End With

Let me know if that helped.

Regards,
Steve

Nigel wrote:

> im having trouble figuring out what is wrong with this code....
> it should use the range set to the variable ProdRange as the source for
> the data, and putting the drop down list in cell A3.....
>
> Dim ProdRange As Range
> Set ProdRange = Range("a7", "a" & Range("EndOfProducts").Offset(-2,
> 0).Row)
> Range("a3").Validation.Add xlValidateList, , , "=" &
> ProdRange.Address
>
> anyone know what im doing wrong?


 
Reply With Quote
 
Nigel
Guest
Posts: n/a
 
      18th Nov 2006
i dont really understand how i would apply that...

the problem is my drop down is showing duplicates and blank cells....

On Nov 17, 6:35 am, wisc...@googlemail.com wrote:
> What exactly is the problem you are experiencing? You might need to
> delete the Validation right before you add it:
>
> With Range("a3").Validation
> .Delete
> .Add ...
> End With
>
> Let me know if that helped.
>
> Regards,
> Steve
>
> Nigel wrote:
> > im having trouble figuring out what is wrong with this code....
> > it should use the range set to the variable ProdRange as the source for
> > the data, and putting the drop down list in cell A3.....

>
> > Dim ProdRange As Range
> > Set ProdRange = Range("a7", "a" & Range("EndOfProducts").Offset(-2,
> > 0).Row)
> > Range("a3").Validation.Add xlValidateList, , , "=" &
> > ProdRange.Address

>
> > anyone know what im doing wrong?


 
Reply With Quote
 
wisccal@googlemail.com
Guest
Posts: n/a
 
      20th Nov 2006
I see. I believe the data validation list always shows all values
within the given range, even if they are duplicates or blanks. You will
need to remove them from your ProdRange. There are a number of posts in
this group that address this specific issue. Specifically, search for
"prevent duplicate in data validation". The second post gives you some
good pointers.

Regards,
Steve

Nigel schrieb:

> i dont really understand how i would apply that...
>
> the problem is my drop down is showing duplicates and blank cells....
>
> On Nov 17, 6:35 am, wisc...@googlemail.com wrote:
> > What exactly is the problem you are experiencing? You might need to
> > delete the Validation right before you add it:
> >
> > With Range("a3").Validation
> > .Delete
> > .Add ...
> > End With
> >
> > Let me know if that helped.
> >
> > Regards,
> > Steve
> >
> > Nigel wrote:
> > > im having trouble figuring out what is wrong with this code....
> > > it should use the range set to the variable ProdRange as the source for
> > > the data, and putting the drop down list in cell A3.....

> >
> > > Dim ProdRange As Range
> > > Set ProdRange = Range("a7", "a" & Range("EndOfProducts").Offset(-2,
> > > 0).Row)
> > > Range("a3").Validation.Add xlValidateList, , , "=" &
> > > ProdRange.Address

> >
> > > anyone know what im doing wrong?


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
data lookup/validation syntax Doug Howell Microsoft Excel Discussion 1 17th Nov 2009 06:01 PM
data lookup/validation syntax Doug Howell Microsoft Excel Programming 2 17th Nov 2009 02:26 PM
VB syntax to test for data validation in a cell Dave O Microsoft Excel Misc 2 26th Jul 2007 09:29 PM
Data Validation Syntax Question Jim & Gail Microsoft Excel Misc 2 7th Apr 2005 04:17 AM
When pasting data into a column with data validation I lose validation check Brad Microsoft Excel Misc 5 17th Apr 2004 01:11 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:38 AM.