I first need to click before I can see the options in the comboboxes. How do I automatically let it show the text? Now its empty (first click the macrobutton.) Thanks!
Mirjam.xlsm
Option Explicit
Private Sub ComboBox1_Change()
Dim index As Integer
index = ComboBox1.ListIndex
ComboBox2.Clear
Select Case index
Case Is = 0
With ComboBox2
.AddItem "To Kill a Mockingbird"
.AddItem "1984 by George Orwell"
.AddItem "Pride and Prehudice"
.AddItem "Harry Potter and the Sorcerer's Stone"
End With
Case Is = 1
With ComboBox2
.AddItem "Dark Lover"
.AddItem "Twilight"
.AddItem "Dead Until Dark"
.AddItem "Darkfever"
End With
Case Is = 2
With ComboBox2
.AddItem "Ender's Game"
.AddItem "Dune"
.AddItem "Brave New World"
.AddItem "Foundation"
End With
End Select
End Sub
Private Sub CommandButton1_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Projecten")
Dim strRange As String
Range("A" & Rows.Count).End(xlUp)(2).Value = Me.ComboBox1.Value
Range("B" & Rows.Count).End(xlUp)(2).Value = Me.ComboBox2.Value
With ws
Range("C" & Rows.Count).End(xlUp)(2).Value = Me.txtOff.Value
End With
End Sub
Private Sub UserForm_Initialize()
With ComboBox1
.AddItem "Fiction"
.AddItem "Romance"
.AddItem "Science - Fiction"
End With
End Sub
Bookmarks