简体   繁体   中英

VBA function call from excel

I am creating a function to concatenate all cells in a range in a single cell. Everything works ok with the function.

Function transposerange(Rg As Range)
    Dim xCell As Range
    Dim xStr As String
    For Each xCell In Rg
        If Not IsEmpty(xCell.Value) Then
            xStr = xStr & xCell.Value & " "
        End If
    Next
    transposerange = Left(xStr, Len(xStr) - 1)
End Function

If I save it in the opened workbook, I can call it from excel. If I save this function to my personal workbook, it doesn't appear in excel when I want to call it.

What am I doing wrong?

If you want use this function in your spreadsheets, type Personal.xlsb!transposerange(somerange). If you want just transposerange you must make add-id comprising this UDF.

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