Joshdaniel
New Member
- Joined
- Apr 30, 2014
- Messages
- 11
I am attempting to have a user form where the user clicks on a button to Add content into a worksheet. The code is as follows.
'Summary: Button for User to Add DAA. User clicks button and userform1 appears.
'User adds DAA, Career Path, Moves applicable Skills and Strengths to the right listbox
'and then hits submit. Submit command then adds the values into the CareerPathing Worksheet.
I am getting an error for subscript out of range but I have a worksheet labeled CareerPathing
'Summary: Button for User to Add DAA. User clicks button and userform1 appears.
'User adds DAA, Career Path, Moves applicable Skills and Strengths to the right listbox
'and then hits submit. Submit command then adds the values into the CareerPathing Worksheet.
Rich (BB code):
Dim i As Integer
Private Sub btnSubmit_Click()
Dim ssheet As Worksheet
Set ssheet = ThisWorkbook.Sheets("CareerPathing") ***SubScript Out of Range Error Here***
nr = ssheet.Cells(Rows.Count, 1).End(xlUp).Row + 1
ssheet.Cells(nr, 1) = Me.tbDAA
ssheet.Cells(nr, 2) = Me.tbCareerPath
ssheet.Cells(nr, 3) = Me.lbSkills_Strengths2
End Sub
Private Sub CheckBox1_Click()
If CheckBox1.Value = True Then
For i = 0 To lbSkills_Strengths.ListCount - 1
lbSkills_Strengths.Selected(i) = True
Next i
End If
If CheckBox1.Value = False Then
For i = 0 To lbSkills_Strengths.ListCount - 1
lbSkills_Strengths.Selected(i) = False
Next i
End If
End Sub
Private Sub CheckBox2_Click()
If CheckBox2.Value = True Then
For i = 0 To lbSkills_Strengths2.ListCount - 1
lbSkills_Strengths2.Selected(i) = True
Next i
End If
If CheckBox2.Value = False Then
For i = 0 To lbSkills_Strengths2.ListCount - 1
lbSkills_Strengths2.Selected(i) = False
Next i
End If
End Sub
Private Sub cmbAdd_Click()
For i = 0 To lbSkills_Strengths.ListCount - 1
If lbSkills_Strengths.Selected(i) = True Then lbSkills_Strengths2.AddItem lbSkills_Strengths.List(i)
Next i
End Sub
Private Sub cmbRemove_Click()
Dim counter As Integer
counter = 0
For i = 0 To lbSkills_Strengths2.ListCount - 1
If lbSkills_Strengths2.Selected(i - counter) Then
lbSkills_Strengths2.RemoveItem (i - counter)
counter = counter + 1
End If
Next i
CheckBox2.Value = False
End Sub
Private Sub lbSkills_Strengths2_Click()
If Target.Column = 3 Then
If oldVal = "" Then
Else
If newVal = "" Then
Else
Target.Value = oldVal & ", " & newVal
End If
End If
End If
End Sub
Private Sub UserForm_Initialize()
With lbSkills_Strengths
.AddItem "Effective Communication"
.AddItem "Technical"
.AddItem "Problem solving"
.AddItem "Creative"
.AddItem "Teamwork"
.AddItem "Planning"
.AddItem "Organization"
.AddItem "Leadership"
.AddItem "Management"
.AddItem "Adaptable"
.AddItem "Flexible"
.AddItem "Professional"
.AddItem "Responsibility"
.AddItem "Work Ethic"
.AddItem "Energy"
.AddItem "Positive Attitude"
.AddItem "Commercial Awareness"
.AddItem "Analytical"
.AddItem "Drive"
.AddItem "Time Management"
.AddItem "Global Skills"
.AddItem "Negotiation"
.AddItem "Numeracy"
.AddItem "Stress Tolerance"
.AddItem "Independence"
.AddItem "decision making"
.AddItem "integrity"
End With
End Sub
I am getting an error for subscript out of range but I have a worksheet labeled CareerPathing
Last edited by a moderator: