excel-vba Use VB constants when available


Example

If MsgBox("Click OK") = vbOK Then

can be used in place of

If MsgBox("Click OK") = 1 Then

in order to improve readability.


Use Object Browser to find available VB constants. View → Object Browser or F2 from VB Editor.

enter image description here

Enter class to search

enter image description here

View members available

enter image description here