Hello,
I'm currently trying to pull data from listbox2 on userform2 to text boxes in userform1. Listbox2 is populated based on a selection/click made on (userform2) listbox1. Listbox2 breaks down the value selected on listbox1 into 1 row and 5 columns.
I'm trying to pull those values into specific textboxes on userform 1. Below is the code I'm using and the error i keep getting is invalid use of null
I'm currently trying to pull data from listbox2 on userform2 to text boxes in userform1. Listbox2 is populated based on a selection/click made on (userform2) listbox1. Listbox2 breaks down the value selected on listbox1 into 1 row and 5 columns.
VBA Code:
Private Sub ListBox1_Click()
Dim LastRow As Integer, CurVal As Variant, X As Integer
'Find last row
LastRow = form.Cells(Rows.Count, "k").End(xlUp).Row
'Clear listbox1
CurVal = Me.ListBox1.Value
For X = 2 To LastRow
With Sheets("form")
If .Cells(X, "k") = CurVal Then
'Found a match; populate listbox2
Me.ListBox2.RowSource = .Range(.Cells(X, "F"), Cells(X, "J")).Address
Exit For
End If
End With
Next X
End Sub
Private Sub Select1_Click()
Dim unit As String
UserForm1.txtMaterial.Value = UserForm2.ListBox2.List(UserForm2.ListBox2.ListIndex, 1)
UserForm1.txtSeries.Value = UserForm2.ListBox2.List(UserForm2.ListBox2.ListIndex, 2)
UserForm1.txtSurface.Value = UserForm2.ListBox2.List(UserForm2.ListBox2.ListIndex, 3)
UserForm1.txtWidth.Value = UserForm2.ListBox2.List(UserForm2.ListBox2.ListIndex, 4)
unit = UserForm2.ListBox2.List(UserForm2.ListBox2.ListIndex, 5)
If measure = "IN" Then 'Edit fucntion checks the checkbox that was previously selected before edit.
UserForm1.CbIN.Value = True
Else
UserForm1.CbMM.Value = True
End If
MsgBox "Please Make the required changes and click on 'Save' button to update.", vbOKOnly + vbInformation, "Select"
End Sub