Home » excel » excel – Use different background colours in vba userform

excel – Use different background colours in vba userform

Posted by: admin May 14, 2020 Leave a comment

Questions:

I have a Userform1 consisting of two ComboBoxes:

Sub UserForm_Activate()
ComboBox1.List = Sheet1.Range("A1:A5").Value
ComboBox2.List = Sheet1.Range("B1:B5").Value
End Sub

ComboBox1 is placed on the left side of the UserForm1.
ComboBox2 is placed on the rigth side of the UserForm1.

Now I want to seperate the “area” of each ComboBox by using a different background colour.
Therefore, I inserted Label1 and changed the BackColor to blue (&H00FF0000&) and Label2 and changed the BackColor to red (&H000000FF&).

All this works fine so far.


However, now my issue is that I cannot put the Labels in the background so the ComboBox1 and ComboBox2 are currently hidden by the Label1 and Label2.

Is there a way how I can put them in the background or any other solution how I can use two different background colours on the UserForm1?

How to&Answers:

Right-click on the label and select “send backward” (may need to do this more than once), or on the combobox and select “bring forward”