View Single Post
 
Old 10-30-2017, 12:12 PM
FionaMcKenzie FionaMcKenzie is offline Windows 10 Office 2016
Novice
 
Join Date: Oct 2017
Location: Surrey, United Kingdom
Posts: 14
FionaMcKenzie is on a distinguished road
Default

You probably haven't declared your variables as a Long.

This should help as a code stub to understand what you have done wrong?

Option Explicit

Private Sub CommandButton1_Click()

Dim lComboBox As Long, lCombBoxCount As Long

lCombBoxCount = Me.ComboBox1.ListCount - 1

With ActiveSheet
For lComboBox = 0 To lCombBoxCount
.Cells(lComboBox + 1, 1).Value = Me.ComboBox1.List(lComboBox)
Next lComboBox
End With
End Sub

Private Sub UserForm_Initialize()

Dim lComboBox As Long

Me.ComboBox1.Clear

For lComboBox = 1 To 10
Me.ComboBox1.AddItem lComboBox
Next lComboBox

End Sub
Reply With Quote