Hi,
Am Wed, 14 Aug 2013 09:43:09 -0700 (PDT) schrieb (e-mail address removed):
Yes, oSheet was defined as
Excel.WorkSheet oSheet = EXL.Sheet["Shhet1"];
and still received the error.
perhaps you see it better in a workbook.
Look here:
https://skydrive.live.com/#cid=9378AAB6121822A3&id=9378AAB6121822A3!326
for the workbook "Validation" and rightclick and download it
Regards
Claus B.
What I get from all this is an automation error is being raised because
of unqualified refs. Hard to say without knowing how oSheet is ref'd
down through.
I get no errors querying the Formula1 property whether hard-entered
delimited string OR named range ref, OR just range ref if on same
sheet. The only way I know to use a list stored on a different sheet is
to assign a global scope name to it. So...
In the Immediate Window:
?Sheets("Sheet2").Cells(1,1).Validation.Formula1
=List1
...where List1 refs A1:A5 on Sheet1. (a b c d e)
When hard-entered a delimited string on Sheet2 DV (a,b,c,d,e) it
returns the delimited string.
So if the property returns a range ref then...
Dim sDVList, vDVList, n&
sDVList = Sheets("Sheet2").Cells(1,1).Validation.Formula1 'wksTarget
vDVList = wkbSource.Range(Mid$(sDVList, 2) '2D array of the DV list
For n = LBound(vDVList) To UBound(vDVList)
MsgBox vDVList(n, 1)
Next
...which gives me these 5 MsgBox prompts...
a
b
c
d
e
When I use a local range ref (ie: =A1:A5) I get that back...
=A1:A5
If the local ref is a local scope defined name then I get that back...
=DVList
...so I guess the easiest way to test if the list is a delimited string
is to check it for common delimiters and exit the loop when found.
Likewise the named range. Check the sheet 1st for a local scope name.
If found the the parent is the sheet containing the DV cell. Otherwise
the parent is the workbook.
Use the Like function to test a local range ref...
If sDVList Like "=A1:A2" Then _
vDVList = wksTarget.Range(Mid$(sDVList, 2))
HTH
--
Garry
Free uenet access at
http://www.eternal-september.org
Classic VB Users Regroup
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion