Problem with VBA code and Range
Errata....
I wrote:
"Jeffrey Marks" wrote:
chtNew.SetSourceData Source:=Range( _
"'OAT Test Charts Data_Crosstab'!$F$1:$K$1,
Range(ActiveCell,ActiveCell.Offset(0,6)).Select" _
) <<<
Syntactically, it should be:
chtNew.SetSourceData Source:=Range( _
"'OAT Test Charts Data_Crosstab'!$F$1:$K$1",
Range(ActiveCell,ActiveCell.Offset(0,6)).Select)
Actually, even the latter form seems strange. If ActiveCell is not in he
'OAT Test Charts Data_Crosstab' worksheet, the specified range is erroneous.
On the other hand, if ActiveCell is in the 'OAT Test Charts Data_Crosstab'
worksheet, why use that qualifier for F1:K1?
Moreover, specifying Range(range1,range2) is dubious because that selects
only the upper-left cell of range1 and the lower-right cell of range2. So
your statement is equivalent to:
chtNew.SetSourceData Source:=Range("F1",ActiveCell.Offset(0,6))
But I wonder if even that makes good sense. Depends on your intent.
PS: I finally did determine that .Select in that context causes a VBA
error.
|