简体   繁体   中英

User-defined Function in VBA Excel is Not Accessible?

I have this function in a module in my VBE, but when I try to access it in my userforms, I get an error because it cannot be detected by VBE: 错误

This is the Col_Letter function:

Function Col_Letter(lngCol As Long) As String
    Dim vArr
    vArr = Split(Cells(1, lngCol).Address(True, False), "$")
    Col_Letter = vArr(0)
End Function

I also tried adding Public :

Public Function Col_Letter(lngCol As Long) As String
    Dim vArr
    vArr = Split(Cells(1, lngCol).Address(True, False), "$")
    Col_Letter = vArr(0)
End Function

Naming a module with the same name as a public funciton is quite a bad idea. Change the name of the Col_Letter module or the name of the function.

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