Thanks for trying. Column H is just a row number, record #, of each record entered starting a 1. A unique ID.
VBA Error - Run-time error '91': Object variable or With block variable not set
I am getting error code 91 but can't determine what I need to fix. Everything looks good but I am clearly not right. This code populates a list box that will populate controls to add training when a line is double ckicked in the box.
Any ideas as to what I can do to fix this?
Private Sub lstLookup_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
'declare the variables
Dim ID As String
Dim I As Integer
Dim findvalue As Range
'get the select value from the listbox
For I = 0 To lstLookup.ListCount - 1
If lstLookup.Selected(I) = True Then
'set the listbox column
ID = lstLookup.List(I, 14)
End If
Next I
'find the value in the range
Set findvalue = Sheet2.Range("H:H").Find(What:=ID, LookIn:=xlValues).Offset(0, -6)
'add the values to the userform controls
cNum = 10
For X = 1 To cNum
Me.Controls("Reg" & X).Value = findvalue
Set findvalue = findvalue.Offset(0, 1)
Next
'disable the controls to make the user select an option
With Me
.cmdAdd.Enabled = False
.cmdAdd.BackColor = RGB(225, 225, 225)
.cmdEdit.Enabled = False
.cmdEdit.BackColor = RGB(225, 225, 225)
.cmdTraining.Enabled = False
.cmdTraining.BackColor = RGB(225, 225, 225)
.optAdd = False
.optEdit = False
.optTraining = False
End With
End Sub
Microsoft 365 and Office | Excel | For home | Windows
Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.
11 answers
Sort by: Most helpful
-
Anonymous
2021-05-13T20:55:49+00:00