ipbr21054
Well-known Member
- Joined
- Nov 16, 2010
- Messages
- 5,899
- Office Version
- 2007
- Platform
- Windows
I currently have a command button on my worksheet that opens a userform.
Then once the userform is open i need to press another command button to run the code & see values in Listboxe & Textboxes.
Here is the code for Sheet command button
Here is the code for userform command button
I have put the userform command button code AFTER ConnectorForm.Show in the sheet command button code thinking when i press the sheet button the form will open & the code will run but
i see the following issue.
What did i do wrong & how to fix it Thanks
Then once the userform is open i need to press another command button to run the code & see values in Listboxe & Textboxes.
Here is the code for Sheet command button
VBA Code:
Private Sub ConnectorUsed_Click()
Dim lastRow As Long
lastRow = Cells(Rows.Count, 6).End(xlUp).Row
Range("A7:L" & lastRow).Sort Key1:=Range("D8:D" & lastRow), _
Order1:=xlAscending, Header:=xlNo
Range("A8").Select
ConnectorForm.Show
End Sub
Here is the code for userform command button
Code:
Private Sub CheckConnectorsUsed_Click()
Dim r As Range, f As Range, Cell As String, added As Boolean
Dim sh As Worksheet
Dim i As Long
Set sh = Sheets("MCLIST")
sh.Select
With ListBox1
.Clear
.ColumnCount = 4
.ColumnWidths = "100;170;70;10"
Set r = Range("C8", Range("C" & Rows.Count).End(xlUp))
Set f = r.Find(TextBox1.Value, After:=r.Cells(r.Count), LookIn:=xlValues, LookAt:=xlPart)
If Not f Is Nothing Then
Cell = f.Address
Do
If Len(Cells(f.Row, "L").Value) <> 0 Then
.AddItem f.Value
.List(.ListCount - 1, 1) = f.Offset(, 1).Value ' MODEL
.List(.ListCount - 1, 2) = f.Offset(, 6).Value ' YEAR
.List(.ListCount - 1, 3) = f.Offset(, 9).Value ' CONNECTOR USED
.List(.ListCount - 1, 4) = f.Row
End If
Set f = r.FindNext(f)
Loop While f.Address <> Cell
.TopIndex = 0
End If
End With
TextBox2.Text = ActiveSheet.Range("L1").Value ' BLACK
TextBox3.Text = ActiveSheet.Range("L2").Value ' CLEAR
TextBox4.Text = ActiveSheet.Range("L3").Value ' GREY
TextBox5.Text = ActiveSheet.Range("L4").Value ' RED
End Sub
I have put the userform command button code AFTER ConnectorForm.Show in the sheet command button code thinking when i press the sheet button the form will open & the code will run but
i see the following issue.
What did i do wrong & how to fix it Thanks