Reputation: 3
I have the UDF Test(rng as range)
and I want to do something like this:
Dim rng2 as Range
Set rng2 = blah blah
rng2.formula = "=test(rng)"
How can I do this?
Upvotes: 0
Views: 164
Reputation: 17637
What if rng
is on another sheet? Then you need this:
rng2.Formula = "=test('" & rng.Parent.Name & "'!" & rng.Address & ")"
Upvotes: 1
Reputation: 13
You have to specify the address of range i.e :
rng2.formula = "=test(" & rng.address & ")"
Upvotes: 0
Reputation: 12645
The range address must be passed as a variable, not a string:
Dim rng2 as Range
Set rng2 = blah blah
rng2.formula = "=test(" & rng.Address & ")"
Upvotes: 1