Hello all,
I have a userform that populates a listbox with the data that matches another cells value. It runs and leaves option button for all results but not always the data from the cell it is recognizing Here is the code. I am thinking of putting in a delay to give the code time to trigger fully.
I have a userform that populates a listbox with the data that matches another cells value. It runs and leaves option button for all results but not always the data from the cell it is recognizing Here is the code. I am thinking of putting in a delay to give the code time to trigger fully.
VBA Code:
Sub Operate_Click()
Dim MCCw As Worksheet
Dim MCCp As ListObject
Dim MCCRP As ListColumn
Dim AGo, WAdress As String
Dim AGoAs, rng, ra, qcell As Range
Dim ADate As Date
Dim rowct As Integer
Set MCCw = ThisWorkbook.Sheets("MCC Projects")
Set MCCp = MCCw.ListObjects("MCC_Projects")
Set MCCRP = MCCp.ListColumns("Responsible person")
'On Error GoTo Line23
If PM_Name <> "" Then
'MsgBox "You Got It!", vbCritical, "2nd Level of Buttons"
AGo = PM_Name.Value
With MCCw.Range("C:C")
Set rng = .Find(What:=AGo, After:=.Cells(1), LookIn:=xlValues, LookAt:=xlWhole, _
SearchOrder:=xlByRows, SearchDirection:=xlPrevious, MatchCase:=False)
If Not rng Is Nothing Then
wAddress = rng.Address
rowct = 0
For Each qcell In MCCw.Range("C:C")
If AGo <> "" Then
If qcell = AGo Then
ProjectIDs_LB.AddItem
ProjectIDs_LB.List(rowct, 0) = qcell(rng.Row, -1).Value 'Product
rowct = rowct + 1
Set rng = .FindNext(rng)
End If
End If
Next qcell
ElseIf rng Is Nothing Then
MsgBox "Name not found" & vbCrLf & "Try Again"
End If
End With
ElseIf PM_Name = "" Then
MsgBox "Add a name", vbCritical + vbOKOnly, "Here we go..."
End If
End Sub