View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 6,953
Default validation list from worksheet given by ref

Well, you have multiple problems I believe. Your sample has several errors
in it. conceptually, it looks like you want to do validation to a list in a
separate workbook. You can't even do validation to a list on a separate
sheet in the same workbook unless you create a named range. As I recall,
you can't do it to a separate workbook. Anyway, this creates the data
validation for a list on another worksheet in the same workbook:

Sub bbb()
Dim RefWS As Worksheet
With Workbooks("RefBookName.xls")
Set RefWS = _
.Worksheets("refSheetname")
.Names.Add _
Name:="List", RefersTo:="=" & _
RefWS.Range("A1:A6").Address(1, 1, xlA1, True)

With .Sheets(1).Range("A1").Validation
.Delete
.Add Type:=xlValidateList, _
Formula1:="=List"
End With
End With
End Sub

YOu can play with that and see what you can do.

--
Regards,
Tom Ogilvy


"Boba" wrote:

"Tom Ogilvy" wrote in message
...
Formula1:="=" & RefWS.Cells("A1:A6").Address(1,1,xlA1,True)
...


Thank you, Tom;
but the code you suggest returns rte=13
(RefWS is a valid reference)