Change Combo Box Value in VBA

dmacmillan

Board Regular
Joined
Apr 5, 2004
Messages
125
Hi,

I'm using a Combo Box to drive graphs in a Dashboard. The Combo Box consists of five values that I want to cycle every 10 seconds.

I have tried a variations of 'combobox.value' and'.ListFillRange' in 'combobox_Change()' without luck.

Thanks in advance,
David
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Thanks. I have tried the following code but am getting 'Run-time Error 70' .... Permission denied. For the record, Range("DateParam") is the ListFillRange for the Combobox cboC10.

Tried to use Code Tags but couldn't find them ...

Private Sub cboC10_Change0()
Dim cDateSeq As Range
Dim ws As Worksheet
Set ws = Worksheets("Parameters")

For Each cDateSeq In ws.Range("DateParam")

With cboC10
.AddItem cDateSeq.Value
End With
Next

End Sub
 
Upvote 0
If you manually entered ListFillRange (or with code) and at the same time use AddItem, then this error occurs. You need to remove all ListFillRange values from Properties (if any) and from code.
 
Upvote 0
Thanks for such a prompt reply. Mighty perplexed ... if I have a ListFillRange, why do I need to use the AddItem method? Is there a why of cycling through the ListFillRange values?
 
Upvote 0
You better ask Microsoft guys. :) ListFillRange and AddItem can't live together.
 
Upvote 0
This will update the LinkedCell and any dependent values and charts, etc. However the value that displays in the combobox itself does not update on the screen.

Code:
Sub RollTheList()
    Dim cbxItem As MSForms.ComboBox, _
        rngList As Excel.Range, _
        strList As String, _
        i%
 
    Set cbxItem = Sheet3.ComboBox1
 
    Let strList = cbxItem.ListFillRange
    Set rngList = Sheet3.Range(strList)
 
    For i = 0 To rngList.Count - 1
        cbxItem.ListIndex = i
        DoEvents
        Application.Wait (Now + TimeSerial(0, 0, 5))
        Debug.Print Now
    Next i
 
End Sub

It's late and I don't remember if or how one can pass a parameter using ONTIME, but that might be one way to get that combobox to show the changes.
 
Last edited:
Upvote 0
Greg,

Thank you for your efforts, I'm definitely moving in the right direction. May revert later if I encounter a snag.

Kind regards,
David
 
Upvote 0
I should probably point out that my code is referencing the worksheet by its CodeName and not by its Name.
 
Upvote 0

Forum statistics

Threads
1,224,600
Messages
6,179,836
Members
452,947
Latest member
Gerry_F

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