As far as I can tell this userform is doing everything its supposed to do, but when then CommandButton4_Click sub is run I recieve a "Object variable or With block variable not set" message, and for the life of me I can't figure out why.
This is the code I'm working with.
Code
Private Sub CommandButton4_Click()
Dim rCount As Range, rAt As Range
Set rCount = Sheets(3).Range("A:A")
x = 1
For Each rAt In rCount
If Not rAt = "" Then
x = x + 1
Else
Exit For
End If
Next
Sheets(3).Cells(x, 1).Value = x
Sheets(3).Cells(x, 2).Value = Date
Sheets(3).Cells(x, 3).Value = ComboBox1
Sheets(3).Cells(x, 4).Value = ComboBox2
Sheets(3).Cells(x, 5).Value = ComboBox3
Sheets(3).Cells(x, 6).Value = TextBox1.Value
Sheets(3).Cells(x, 7).Value = TextBox2.Value
Unload UserForm1
End Sub
Display More
Code
Private Sub UserForm_Initialize()
Dim rCount As Range, rAt As Range
Set rCount = Sheets(3).Range("A:A")
x = 1
For Each rAt In rCount
If Not rAt = "" Then
x = x + 1
Else
Exit For
End If
Next
Dim a As Range
Dim box1list As Range
Dim box2list As Range
Dim box3list As Range
Set box1list = Sheets(2).Range("a:a")
Set box2list = Sheets(2).Range("b:b")
Set box3list = Sheets(2).Range("c:c")
TextBox3.Value = x
TextBox4.Value = Date
For Each a In box1list
If a = "" Then
Exit For
Else
ComboBox1.AddItem a
End If
Next
For Each a In box2list
If a = "" Then
Exit For
Else
ComboBox2.AddItem a
End If
Next
For Each a In box3list
If a = "" Then
Exit For
Else
ComboBox3.AddItem a
End If
Next
UserForm1.Show
End Sub
Private Sub UserForm_Terminate()
Unload UserForm1
End Sub
Display More