Happy Wednesday!
I'm working with a UserForm that I created (called frmSubMaintenance) that pulls information from a sheet (called DataCenter) and allows me to edit and save the results back to DataCenter. There are two command buttons with rather simple code that do the work. Here's the first one. It works as designed:
Here's the second. Almost the same code but it doesn't do anything:
Here's what DataCenter looks like. Sub Name is in column E and Sub Code is in column B.
When I use the cmdSearchSubName command button all the relevant information is pulled as desired.
When I use the cmdSearchSubCode command button nothing happens. No error no data.
Thoughts?
I'm working with a UserForm that I created (called frmSubMaintenance) that pulls information from a sheet (called DataCenter) and allows me to edit and save the results back to DataCenter. There are two command buttons with rather simple code that do the work. Here's the first one. It works as designed:
VBA Code:
Private Sub cmdSearchSubName_Click()
Dim SubName_id As String
SubName = Trim(SubName.Text)
lastrow = Worksheets("DataCenter").Cells(Rows.Count, 5).End(xlUp).Row
For i = 1 To lastrow
If Worksheets("DataCenter").Cells(i, 5).Value = SubName Then
SubCode.Text = Worksheets("DataCenter").Cells(i, 2).Value
SubInitials.Text = Worksheets("DataCenter").Cells(i, 4).Value
FieldManager.Text = Worksheets("DataCenter").Cells(i, 7).Value
End If
Next
End Sub
Here's the second. Almost the same code but it doesn't do anything:
VBA Code:
Private Sub cmdSearchSubCode_Click()
Dim SubCode_id As String
SubCode = Trim(SubCode.Text)
lastrow = Worksheets("DataCenter").Cells(Rows.Count, 2).End(xlUp).Row
For i = 1 To lastrow
If Worksheets("DataCenter").Cells(i, 2).Value = SubCode Then
SubName.Text = Worksheets("DataCenter").Cells(i, 5).Value
SubInitials.Text = Worksheets("DataCenter").Cells(i, 4).Value
FieldManager.Text = Worksheets("DataCenter").Cells(i, 7).Value
End If
Next
End Sub
Here's what DataCenter looks like. Sub Name is in column E and Sub Code is in column B.
When I use the cmdSearchSubName command button all the relevant information is pulled as desired.
When I use the cmdSearchSubCode command button nothing happens. No error no data.
Thoughts?