Compile Error: Variable not defined
I keep on getting msg 'Compile Error: Variable not defined' when I try to run this code. It seems to be when it reaches 'tbxLoadRef2' yet this object does exist within the active userform. Can anybody help me please!
Private Sub cbnAmend_Click()
' Search Database for valid reference
Dim LoadRef As Variant
Windows("SourceWB.xls").Activate
Sheets("Loadings").Select
Range("A1").Offset(1, 0).Select
Range(Selection, Selection.End(xlDown)).Select
With Selection
Set LoadRef = .Find(Listbox1.Text, LookIn:=xlValues)
End With
' Close userform
Unload Me
' Select found value
Windows("SourceWB").Activate
Sheets("Loadings").Select
LoadRef.Select
' Open userform
frmAmendLoad.Show
' Populate userform with info from worksheet
tbxLoadRef2.Text = Selection.Value
Selection.Offset(0, 4).Select
tbxSuppRef.Text = Selection.Value
ActiveCell.Offset(0, -ActiveCell.Column + 2).Select
tbxDate2.Text = Selection.Value
End Sub
|