Finance

Charts

Statistics

Macros

Search

Specifying Default Values for Optional Parameters with Excel VBA

For an optional parameter, you can specify a default value.

In the following example, default intensities are set for the red, green, and blue components of the color of the selected cell range.

Specifying a default value for an optional parameter

Sub Color(Optional Red As Integer = 0, Optional Green As Integer = 255, _
          Optional Blue As Integer = 0)
    Selection.Interior.Color = RGB(Red, Green, Blue)
End Sub

Sub DemoDefaultValues()
    Color Blue:=175
End Sub
0 0 votes
Évaluation de l'article
S’abonner
Notification pour
guest
0 Commentaires
Le plus ancien
Le plus récent Le plus populaire
Online comments
Show all comments
Facebook
Twitter
LinkedIn
WhatsApp
Email
Print
0
We’d love to hear your thoughts — please leave a commentx