Show different value in ComboBox from selected list

nubranger

Board Regular
Joined
Dec 23, 2019
Messages
53
Office Version
  1. 365
Platform
  1. Windows
I have a ComboBox (Quart1) in a userform with the ff list of items added at Userform Initialize:

VBA Code:
Private Sub UserForm_Initialize()

    With Quart1
    
         .AddItem "Q1 (Jan to Mar)"
         .AddItem "Q2 (Apr to Jun)"
         .AddItem "Q3 (Jul to Sep)"
         .AddItem "Q4 (Oct to Dec)"
         
    End With

What I want to do is when, say "Q1 (Jan to Mar)" is selected, the value of the ComboBox to show "Q1" instead of "Q1 (Jan to Mar)". I use the the following code but I am getting invalid value property at Me.Quart1.VAlue = "Q1" line.

VBA Code:
Private Sub Quart1_Change()

    Me.QuarterLabel.Caption = "Select Year"
    
    If Quart1.Value = "Q1 (Jan to Mar)" Then
    Me.Quart1.Value = "Q1"
    End If
    

End Sub
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Welcome to the forum!

One would have to reset the whole list to do that. It might be more efficient to parse that part out to a label or cell. Here is how to parse it.
VBA Code:
Private Sub Quart1_Change()
    QuarterLabel.Caption = "Select Year"
    MsgBox Split(Quart1)(0)
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,896
Messages
6,175,260
Members
452,627
Latest member
KitkatToby

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top