Hi, abjac,
this is sort of a double thread as you would need to write the contents from Sheet2 to Sheet3 and only after that start deleting possible entries from Sheet3 on Sheet2.
Sub EF938606_a()
'collect the data for one person in Sheet3
Dim varName As Variant
Dim strName As String
Dim lngCounter As Long
strName = InputBox("Type Name to find entry for.?")
If strName = "" Then Exit Sub
With Worksheets("Sheet2")
' .Unprotect Password:="1111"
varName = Application.Match(strName, .Range(.Cells(7, 5), .Cells(Rows.Count, 5)), 0)
If Not IsError(varName) Then
Application.ScreenUpdating = False
varName = varName - 1
If Worksheets("Sheet3").Range("E" & Rows.Count).End(xlUp).Row > 7 Then
Worksheets("Sheet3").Range("E9:E" & Worksheets("Sheet3").Range("E" & Rows.Count).End(xlUp).Row).EntireRow.Delete
End If
For lngCounter = 0 To 51
If WorksheetFunction.CountBlank(.Range("F" & 7 + varName + lngCounter * 30).Resize(1, 6)) < 6 Then
.Range("E" & 7 + lngCounter * 30).Resize(2, 7).Copy
With Worksheets("Sheet3").Range("E" & Rows.Count).End(xlUp).Offset(2, 0)
.PasteSpecial xlPasteValues
.PasteSpecial xlPasteFormats
End With
.Range("E" & 7 + varName + lngCounter * 30).Resize(1, 7).Copy
With Worksheets("Sheet3").Range("E" & Rows.Count).End(xlUp).Offset(1, 0)
.PasteSpecial xlPasteValues
.PasteSpecial xlPasteFormats
End With
End If
Next lngCounter
End If
' .Protect Password:="1111", DrawingObjects:=True, Contents:=True, Scenarios:=True
End With
Application.ScreenUpdating = True
End Sub
Sub EF938606_b()
'delete the data for one person and one entry in Sheet2
Dim varName As Variant
Dim varStart As Variant
Dim strName As String
Dim lngCounter As Long
If ActiveSheet.Name <> "Sheet3" Then Exit Sub
strName = Worksheets("Sheet3").Range("E11").Value
If strName = "" Then Exit Sub
If Selection.Count > 1 Then Exit Sub
If Selection = "" Then Exit Sub
If (Selection.Row - 7) Mod 4 <> 0 Then Exit Sub
If Selection.Column < 6 Or Selection.Column > 11 Then Exit Sub
With Worksheets("Sheet2")
.Unprotect Password:="1111"
varStart = Application.Match(CDbl(Worksheets("Sheet3").Cells(Selection.Row - 2, "F")), .Columns(6), 0)
If Not IsError(varStart) Then
varName = Application.Match(strName, .Range(.Cells(varStart, 5), .Cells(Rows.Count, 5)), 0)
varName = varName - 1
If Not IsError(varName) Then
.Cells(varStart + varName, Selection.Column).ClearContents
End If
End If
.Protect Password:="1111", DrawingObjects:=True, Contents:=True, Scenarios:=True
End With
With Selection
.ClearContents
.Interior.Pattern = xlNone
End With
End Sub
HTH,
Holger
Bookmarks