Private Sub ListofData_Click()
Dim rngMyData As Range
Set rngMyData = Sheets("Sheet1").Columns("A")
On Error Resume Next
txtRowNumber = Application.WorksheetFunction.Match(txtIssue.Value, rngMyData, 0)
On Error Resume Next
If Val(txtRowNumber) > 1 Then 'Exclude the ability to change the header row.
cmdUpdate.Enabled = True 'OK to enable the button as an applicable row number has been returned
End If
End Sub
Private Sub cmdUpdate_Click()
Dim lngMyRow As Long
lngMyRow = Val(txtRowNumber)
If lngMyRow = 0 Then
MsgBox "Update is not available as a row number for the selected issue could not be found.", vbExclamation
Exit Sub
Else
Cells(lngMyRow, "A").Value = txtIssue.Text
Cells(lngMyRow, "C").Value = txtDateReceived.Text
Cells(lngMyRow, "D").Value = txtAgency.Text
Cells(lngMyRow, "E").Value = txtService.Text
Cells(lngMyRow, "F").Value = txtSource.Text
Cells(lngMyRow, "G").Value = txtIssueType.Text
Cells(lngMyRow, "H").Value = txtIssueNonIssue.Text
Cells(lngMyRow, "I").Value = txtOwnership.Text
Cells(lngMyRow, "J").Value = txtTimeSpent.Text
Cells(lngMyRow, "K").Value = txtDateCompleted.Text
Cells(lngMyRow, "L").Value = txtActiveDuration.Text
End If
'Refresh the list
Me.ListOfData.RowSource = "ListOfData"
End Sub
Bookmarks