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?
What if rng is on another sheet? Then you need this:
rng2.Formula = "=test('" & rng.Parent.Name & "'!" & rng.Address & ")"
ActiveSheet in particular. I would remove the If check and simply refer to the parent names of both rng (input) and rng2 (output).rng2 as we're dealing with the object directly - agreed there's no need for the ActiveSheet check as the address will still work with the sheet name even if it's on the same sheet so can be reduced to just one IIf() statement. Will update when I get back to a computer!