oh no oh dear
oh no oh dear

Reputation: 27

Pass a colour picker colour into a variable

Is there a way to pass a colour selected from the inbuilt picker into a variable? Something like this?

newColour = Application.Dialogs(xlDialogEditColor).Show(1)

If not, what is the best way to go about getting colours from a GUI into a variable so it is easy for the user to change colours?

Thanks.

Upvotes: 2

Views: 2839

Answers (1)

YowE3K
YowE3K

Reputation: 23974

Your code is asking the user to select a new colour for colour 1, and return True to the variable newColour if the user selects a colour, or False if they cancel.

So you would be able to use your code as

newColour = Application.Dialogs(xlDialogEditColor).Show(1)
If newColour Then
    Range("A1").Interior.Color = ActiveWorkbook.Colors(1)
End If

Upvotes: 4

Related Questions