Thanks for the very useful tips! Now I have enough round and square bracket and other tricks to wrap up the function! The double square bracket trick in test[[varname]] is golden! Thanks again, Sander.