ComboBox Property will not change value

Chiznuggets

New Member
Joined
Jun 26, 2019
Messages
8
Hello,

I'm creating a User Form and trying to get the starting position of a Combo Box to be the number of the month. For example since it is currently July I would like the Combo Box to start on position 6.

When I try this
Code:
varToday = Date    
    varToday = varToday - 10 'this is purposeful
    
    varToday = Format(varToday, "mm-dd-yy")
     
    lngStart = Month(varToday)
    
    boxDate.SelStart = lngStart - 1

All the variables except boxDate.SelStart acquire the desired value when I step through the program. It is staying as a value of 0 while the lngStart is a 6. Any ideas? I have all this code in the Userform under the initialize section.
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
It looks like your combobox has a list of months, and you'd like the current (adjusted) month selected upon initialization. If so, try the following instead...

Code:
    With Me.boxDate
        .Value = .List(Month(Date - 10) - 1)
    End With

Hope this helps!
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,818
Messages
6,181,152
Members
453,021
Latest member
Justyna P

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