简体   繁体   中英

VBA User-defined functions in Office 365

Some MS Office versions place restrictions on user-defined functions. Specifically, UDFs cannot write to the excel worksheet outside the cells that call the function .

My question: does this restriction apply in Office 365 as well?

The same restriction applies to all Office versions and editions. There were no breaking changes so far, especially for Office 365 applications.

You can change more than one cell if you use dynamic Spilling:

Public Function Stooges() As Variant
    Dim arr(1 To 3) As Variant
    
    arr(1) = "Larry"
    arr(2) = "Moe"
    arr(3) = "Curly"
    
    Stooges = arr
End Function

在此处输入图像描述

Note that in Excel 365, array-entry is not required.

Thanks everyone,

The answer is "No". Excel 365 allows more flexibility.

The answer by @Gary'sStudent led me to look for "spilling" and "dynamic arrays". These are featured that were added in Excel 365. Here are the references:

Spilling

Custom functions and dynamic arrays

Thanks!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM