To correct an existing excel macro, so that it selects and deletes the correct name and data
## Deliverables
The existing macro for delteing people and thier data from the spreadsheets, displays a box with both the first name and last name, however on selecting the person to be deleted, the macro only selects by last name, selecting the first match it comes to, I need the deleting process to take account of first name and last name, and only delete the correct person and data if necessary, BELOW IS THE EXISTING MACRO TO BE MODIFIED
Private Sub CommandButton1_Click()
Select Case MsgBox("Do you want to delete all of the data held for this person?", vbYesNoCancel, "Delete all data")
Case vbYes
deletePersonData
deletePerson
Case vbNo
deletePerson
Case Else
Exit Sub
End Select
End Sub
Private Sub CommandButton2_Click()
End
End Sub
Private Sub ListBox1_Change()
If [login to view URL] = -1 Then
[login to view URL] = False
Else
[login to view URL] = True
End If
End Sub
Private Sub UserForm_Initialize()
Dim row As Integer
row = 6
Do
If Not [login to view URL]([login to view URL](row, 2)) And Not [login to view URL](row, 4) = "" Then
[login to view URL] ([login to view URL](row, 4) + ", " + [login to view URL](row, 3))
End If
row = row + 1
Loop While (row < 150)
End Sub
Private Sub deletePerson()
Dim n As Integer
n = findPerson
[login to view URL](n, 2) = "00000000"
[login to view URL](n, 3) = ""
[login to view URL](n, 4) = ""
[login to view URL](n, 5) = ""
[login to view URL](n, 6) = ""
[login to view URL](n, 7) = ""
[login to view URL] ([login to view URL])
End Sub
Private Sub deletePersonData()
Dim n, col As Integer
n = findPerson
col = 15
For col = 14 To 195
[login to view URL](n, col) = ""
Next
For col = 14 To 197
[login to view URL](n, col) = ""
Next
End Sub
Private Function findPerson() As Integer
Dim loopExit As Boolean
Dim n As Integer
n = 6
returnValue = True
loopExit = False
Do
If [login to view URL](n, 4) = Split([login to view URL], ",")(0) Then
loopExit = True
Else
n = n + 1
End If
Loop While Not loopExit
findPerson = n
End Function