开发者

"User-defined type not defined" for simple custom type

开发者 https://www.devze.com 2023-02-04 05:10 出处:网络
In Excel 2007 I have the following very simple code in VBA: Public Type specType sb As Long End Type Private Sub MyButton_Click()

In Excel 2007 I have the following very simple code in VBA:

Public Type specType
    sb As Long
End Type


Private Sub MyButton_Click()
    Dim spec As specType

    '...
End Sub

Whe开发者_JAVA百科n the button is clicked, i get a "User-defined type not defined" Error on the "Dim spec As specType" line... why? Do I have to move my user defined types to a special location?


Turns out Types have to be defined before any functions in the module, otherwise they simply won't be recognized (without giving you an error).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号