I have a workbook with two worksheets: Sheet1 = named Find and Sheet2 =named MasterData. On Sheet2 I have a created a table named Table2
I am have created a Userform to interact with the MasterData table2 but continue to get errors when I try to create SET statement in the module.
Here are the Dim statements in procedure:
Dim wb As Workbook
Dim ws1 As Worksheet
Dim tbl1 As ListObject
The module I am having trouble with should process like this (after clicking a record in the forms listbox it should select that records info from sheet2 data and fill individual text boxes)
Here is the code section (with lines identified as showing errors)
Private Sub lbo1_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
If Me.lbo1.ListIndex = -1 Then Exit Sub
If Me.lbo1.ListIndex > -1 Then sc = Me.lbo1.ListIndex + 2
ClearForm
Set ws1 = wb.Sheets("Sheet2") 'errors out
Set tbl1 = ws1.ListObjects("Table2") 'errors out
With tbl1
For i = 1 To 6
Controls("txtbox" & i).Value = .Range(sc, i)
Next i
End With
End Sub
How should these SET statements be modified? Thank you.