LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Validation using VBA

I want to addd validation to cells on a spreadsheet using
VBA. I am setting up the spreadsheet with data and
formating using VBA, and want to addd validation to a
column during this process. The data for the list is on a
worksheet called "Contractors", and the validation cell is
R4 on whatever sheet is active at the time of running the
code. I have tried the following code:

For l = 1 To 20

Worksheets("Contractors").Select
Cells(l, 1).Select
contract = ActiveCell.Value
list(l) = contract

Next l

Worksheets(shtname).Select

test = list(1)
For l = 2 To 20

test1 = list(l)
test = test & "," & test1

Next l
With Range("R4").Validation

.Add Type:=xlValidateList, Formula1:=test

I get an error message saying "Application-defined or
object-defined error".

The range containing the data which is A1:A20, is also
named, but using the name doesn't help either.

Any help would be great.
Regards

David C


 
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
Validation Data using Validation Table cell range..... Dermot Excel Discussion (Misc queries) 16 January 5th 10 09:35 PM
data validation invalid in dynamic validation list ilia Excel Discussion (Misc queries) 0 November 7th 06 12:54 PM
Validation (Drop down list vs simple text length validation) Bob Phillips[_6_] Excel Programming 2 April 27th 04 07:47 PM
Validation (Drop down list vs simple text length validation) Jason Morin[_2_] Excel Programming 1 April 27th 04 04:56 PM
Validation (Drop down list vs simple text length validation) Pete McCosh Excel Programming 0 April 27th 04 03:49 PM


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